@@ -35,7 +35,7 @@ def __init__(self, bot):
3535 self .__config .register_guild (** defaultsguild )
3636 self .__config .register_global (** defaults )
3737 self .loop = bot .loop .create_task (self .unmute_loop ())
38- self .loop = bot .loop .create_task (self .unban_loop ())
38+ self .loop2 = bot .loop .create_task (self .unban_loop ())
3939
4040 # Removes main mods mute commands.
4141 voice_mute = None
@@ -53,6 +53,7 @@ def __init__(self, bot):
5353
5454 def cog_unload (self ):
5555 self .loop .cancel ()
56+ self .loop2 .cancel ()
5657
5758 async def unmute_loop (self ):
5859 while True :
@@ -457,31 +458,26 @@ async def unban_loop(self):
457458 for guild in tempbanned :
458459 for user in tempbanned [guild ]:
459460 if datetime .fromtimestamp (tempbanned [guild ][user ]["expiry" ]) < datetime .now ():
460- user = discord .utils .get (bans , id = user )
461- if not user :
462- async with self .__config .tempbanned () as tempbanned :
463- del tempbanned [guild ][user ]
461+ try :
462+ await guild .unban (user , reason = "Expired temporary ban." )
463+ except discord .HTTPException :
464+ del tempbanned [guild ][user ]
465+ return
464466 else :
465467 try :
466- await guild .unban (user , reason = "Expired temporary ban." )
467- except discord .HTTPException :
468- return
468+ await modlog .create_case (
469+ self .bot ,
470+ guild ,
471+ datetime .utcnow (),
472+ "unban" ,
473+ user ,
474+ author ,
475+ "Expired temporary ban." ,
476+ until = None ,
477+ channel = None ,
478+ )
479+ except RuntimeError as e :
480+ await ctx .send (e )
469481 else :
470- try :
471- await modlog .create_case (
472- self .bot ,
473- guild ,
474- datetime .utcnow (),
475- "unban" ,
476- user ,
477- author ,
478- "Expired temporary ban." ,
479- until = None ,
480- channel = None ,
481- )
482- except RuntimeError as e :
483- await ctx .send (e )
484- else :
485- async with self .__config .tempbanned () as tempbanned :
486- del tempbanned [guild ][user ]
482+ del tempbanned [guild ][user ]
487483 await asyncio .sleep (15 )
0 commit comments