55
55
class ModmailBot (commands .Bot ):
56
56
57
57
def __init__ (self ):
58
- super ().__init__ (command_prefix = self . get_pre )
58
+ super ().__init__ (command_prefix = None ) # implemented in `get_prefix`
59
59
self .version = __version__
60
60
self .start_time = datetime .utcnow ()
61
61
self .threads = ThreadManager (self )
@@ -75,6 +75,9 @@ def __init__(self):
75
75
self ._add_commands ()
76
76
self .owner = None
77
77
78
+ async def get_prefix (self , message = None ):
79
+ return [self .prefix , f'<@{ self .user .id } > ' , f'<@!{ self .user .id } > ' ]
80
+
78
81
def _add_commands (self ):
79
82
"""Adds commands automatically"""
80
83
self .remove_command ('help' )
@@ -199,11 +202,6 @@ def recipient_color(self):
199
202
else :
200
203
return color
201
204
202
- @staticmethod
203
- async def get_pre (bot , message ): # TODO: there gotta be a better way
204
- """Returns the prefix."""
205
- return [bot .prefix , f'<@{ bot .user .id } > ' , f'<@!{ bot .user .id } > ' ]
206
-
207
205
async def on_connect (self ):
208
206
print (line )
209
207
print (Fore .CYAN , end = '' )
@@ -343,8 +341,7 @@ async def get_context(self, message, *, cls=commands.Context):
343
341
if self ._skip_check (message .author .id , self .user .id ):
344
342
return ctx
345
343
346
- # TODO: Can be replaced with await `self.get_pre(self, None)`?
347
- prefixes = [self .prefix , f'<@{ bot .user .id } > ' , f'<@!{ bot .user .id } > ' ]
344
+ prefixes = await self .get_prefix ()
348
345
349
346
invoked_prefix = discord .utils .find (view .skip_string , prefixes )
350
347
if invoked_prefix is None :
0 commit comments