@@ -86,7 +86,9 @@ def __init__(self):
8686 try :
8787 self .db = AsyncIOMotorClient (mongo_uri ).modmail_bot
8888 except ConfigurationError as e :
89- logger .critical ("Your MONGO_URI is copied wrong, try re-copying from the source again." )
89+ logger .critical (
90+ "Your MONGO_URI is copied wrong, try re-copying from the source again."
91+ )
9092 logger .critical (str (e ))
9193 sys .exit (0 )
9294
@@ -213,7 +215,9 @@ def owner_ids(self):
213215 owner_ids = set (map (int , str (owner_ids ).split ("," )))
214216 if self .owner_id is not None :
215217 owner_ids .add (self .owner_id )
216- permissions = self .config ["level_permissions" ].get (PermissionLevel .OWNER .name , [])
218+ permissions = self .config ["level_permissions" ].get (
219+ PermissionLevel .OWNER .name , []
220+ )
217221 for perm in permissions :
218222 owner_ids .add (int (perm ))
219223 return owner_ids
@@ -230,13 +234,16 @@ def log_channel(self) -> typing.Optional[discord.TextChannel]:
230234 channel = self .get_channel (int (channel_id ))
231235 if channel is not None :
232236 return channel
233- logger .debug (' LOG_CHANNEL_ID was invalid, removed.' )
237+ logger .debug (" LOG_CHANNEL_ID was invalid, removed." )
234238 self .config .remove ("log_channel_id" )
235239 if self .main_category is not None :
236240 try :
237241 channel = self .main_category .channels [0 ]
238242 self .config ["log_channel_id" ] = channel .id
239- logger .warning ("No log channel set, setting #%s to be the log channel." , channel .name )
243+ logger .warning (
244+ "No log channel set, setting #%s to be the log channel." ,
245+ channel .name ,
246+ )
240247 return channel
241248 except IndexError :
242249 pass
@@ -268,7 +275,9 @@ def aliases(self) -> typing.Dict[str, str]:
268275 def token (self ) -> str :
269276 token = self .config ["token" ]
270277 if token is None :
271- logger .critical ("TOKEN must be set, set this as bot token found on the Discord Dev Portal." )
278+ logger .critical (
279+ "TOKEN must be set, set this as bot token found on the Discord Dev Portal."
280+ )
272281 sys .exit (0 )
273282 return token
274283
@@ -321,11 +330,13 @@ def main_category(self) -> typing.Optional[discord.CategoryChannel]:
321330 if cat is not None :
322331 return cat
323332 self .config .remove ("main_category_id" )
324- logger .debug (' MAIN_CATEGORY_ID was invalid, removed.' )
333+ logger .debug (" MAIN_CATEGORY_ID was invalid, removed." )
325334 cat = discord .utils .get (self .modmail_guild .categories , name = "Modmail" )
326335 if cat is not None :
327336 self .config ["main_category_id" ] = cat .id
328- logger .debug ("No main category set explicitly, setting category \" Modmail\" as the main category." )
337+ logger .debug (
338+ 'No main category set explicitly, setting category "Modmail" as the main category.'
339+ )
329340 return cat
330341 return None
331342
@@ -404,7 +415,7 @@ async def setup_indexes(self):
404415 ("key" , "text" ),
405416 ]
406417 )
407- logger .debug (' Successfully set up database indexes.' )
418+ logger .debug (" Successfully set up database indexes." )
408419
409420 async def on_ready (self ):
410421 """Bot startup, sets uptime."""
@@ -413,7 +424,7 @@ async def on_ready(self):
413424 await self .wait_for_connected ()
414425
415426 if self .guild is None :
416- logger .debug (' Logging out due to invalid GUILD_ID.' )
427+ logger .debug (" Logging out due to invalid GUILD_ID." )
417428 return await self .logout ()
418429
419430 logger .line ()
@@ -444,12 +455,12 @@ async def on_ready(self):
444455
445456 if not thread :
446457 # If the channel is deleted
447- logger .debug (' Failed to close thread for recipient %s.' , recipient_id )
458+ logger .debug (" Failed to close thread for recipient %s." , recipient_id )
448459 self .config ["closures" ].pop (recipient_id )
449460 await self .config .update ()
450461 continue
451462
452- logger .debug (' Closing thread for recipient %s.' , recipient_id )
463+ logger .debug (" Closing thread for recipient %s." , recipient_id )
453464
454465 await thread .close (
455466 closer = self .get_user (items ["closer_id" ]),
@@ -579,7 +590,7 @@ async def _process_blocked(self, message: discord.Message) -> bool:
579590 reaction = blocked_emoji
580591 changed = False
581592 delta = human_timedelta (min_account_age )
582- logger .debug (' Blocked due to account age, user %s.' , message .author .name )
593+ logger .debug (" Blocked due to account age, user %s." , message .author .name )
583594
584595 if str (message .author .id ) not in self .blocked_users :
585596 new_reason = (
@@ -603,7 +614,7 @@ async def _process_blocked(self, message: discord.Message) -> bool:
603614 reaction = blocked_emoji
604615 changed = False
605616 delta = human_timedelta (min_guild_age )
606- logger .debug (' Blocked due to guild age, user %s.' , message .author .name )
617+ logger .debug (" Blocked due to guild age, user %s." , message .author .name )
607618
608619 if str (message .author .id ) not in self .blocked_users :
609620 new_reason = (
@@ -628,13 +639,15 @@ async def _process_blocked(self, message: discord.Message) -> bool:
628639 ):
629640 # Met the age limit already, otherwise it would've been caught by the previous if's
630641 reaction = sent_emoji
631- logger .debug ('No longer internally blocked, user %s.' , message .author .name )
642+ logger .debug (
643+ "No longer internally blocked, user %s." , message .author .name
644+ )
632645 self .blocked_users .pop (str (message .author .id ))
633646 else :
634647 reaction = blocked_emoji
635648 end_time = re .search (r"%(.+?)%$" , reason )
636649 if end_time is not None :
637- logger .debug (' No longer blocked, user %s.' , message .author .name )
650+ logger .debug (" No longer blocked, user %s." , message .author .name )
638651 after = (
639652 datetime .fromisoformat (end_time .group (1 )) - now
640653 ).total_seconds ()
@@ -643,7 +656,7 @@ async def _process_blocked(self, message: discord.Message) -> bool:
643656 reaction = sent_emoji
644657 self .blocked_users .pop (str (message .author .id ))
645658 else :
646- logger .debug (' User blocked, user %s.' , message .author .name )
659+ logger .debug (" User blocked, user %s." , message .author .name )
647660 else :
648661 reaction = sent_emoji
649662
@@ -652,7 +665,7 @@ async def _process_blocked(self, message: discord.Message) -> bool:
652665 try :
653666 await message .add_reaction (reaction )
654667 except (discord .HTTPException , discord .InvalidArgument ):
655- logger .warning (' Failed to add reaction %s.' , reaction , exc_info = True )
668+ logger .warning (" Failed to add reaction %s." , reaction , exc_info = True )
656669 return str (message .author .id ) in self .blocked_users
657670
658671 async def process_modmail (self , message : discord .Message ) -> None :
@@ -839,9 +852,13 @@ async def on_raw_reaction_add(self, payload):
839852 if isinstance (channel , discord .DMChannel ):
840853 if str (reaction ) == str (close_emoji ): # closing thread
841854 try :
842- recipient_thread_close = strtobool (self .config ["recipient_thread_close" ])
855+ recipient_thread_close = strtobool (
856+ self .config ["recipient_thread_close" ]
857+ )
843858 except ValueError :
844- recipient_thread_close = self .config .remove ("recipient_thread_close" )
859+ recipient_thread_close = self .config .remove (
860+ "recipient_thread_close"
861+ )
845862 if not recipient_thread_close :
846863 return
847864 thread = await self .threads .find (recipient = user )
@@ -875,7 +892,7 @@ async def on_guild_channel_delete(self, channel):
875892
876893 if isinstance (channel , discord .CategoryChannel ):
877894 if self .main_category .id == channel .id :
878- logger .debug (' Main category was deleted.' )
895+ logger .debug (" Main category was deleted." )
879896 self .config .remove ("main_category_id" )
880897 await self .config .update ()
881898 return
@@ -884,14 +901,14 @@ async def on_guild_channel_delete(self, channel):
884901 return
885902
886903 if self .log_channel is None or self .log_channel .id == channel .id :
887- logger .info (' Log channel deleted.' )
904+ logger .info (" Log channel deleted." )
888905 self .config .remove ("log_channel_id" )
889906 await self .config .update ()
890907 return
891908
892909 thread = await self .threads .find (channel = channel )
893910 if thread :
894- logger .debug (' Manually closed channel %s.' , channel .name )
911+ logger .debug (" Manually closed channel %s." , channel .name )
895912 await thread .close (closer = mod , silent = True , delete_channel = False )
896913
897914 async def on_member_remove (self , member ):
@@ -1062,7 +1079,8 @@ async def after_post_metadata(self):
10621079if __name__ == "__main__" :
10631080 try :
10641081 import uvloop
1065- logger .debug ('Setting up with uvloop.' )
1082+
1083+ logger .debug ("Setting up with uvloop." )
10661084 uvloop .install ()
10671085 except ImportError :
10681086 pass
0 commit comments