@@ -135,10 +135,13 @@ def __init__(self, bot: DCSServerBot, listener: Type[MissionEventListener] = Non
135135 self .update_channel_name .add_exception_type (AttributeError )
136136 self .update_channel_name .start ()
137137 self .afk_check .start ()
138+ self .check_for_unban .add_exception_type (psycopg .DatabaseError )
138139 self .check_for_unban .start ()
139140 self .expire_token .add_exception_type (psycopg .DatabaseError )
140141 self .expire_token .start ()
141142 if self .bot .locals .get ('autorole' , {}):
143+ self .check_roles .add_exception_type (psycopg .DatabaseError )
144+ self .check_roles .add_exception_type (discord .errors .DiscordException )
142145 self .check_roles .start ()
143146
144147 async def cog_unload (self ):
@@ -1872,25 +1875,22 @@ async def expire_token(self):
18721875
18731876 @tasks .loop (minutes = 1.0 )
18741877 async def check_for_unban (self ):
1875- try :
1876- async with self .apool .connection () as conn :
1877- async with conn .transaction ():
1878- cursor = await conn .execute ("""
1879- SELECT ucid FROM bans WHERE banned_until < (NOW() AT TIME ZONE 'utc')
1880- """ )
1881- rows = await cursor .fetchall ()
1882- for row in rows :
1883- for server in self .bot .servers .values ():
1884- if server .status not in [Status .PAUSED , Status .RUNNING , Status .STOPPED ]:
1885- continue
1886- await server .send_to_dcs ({
1887- "command" : "unban" ,
1888- "ucid" : row [0 ]
1889- })
1890- # delete unbanned accounts from the database
1891- await conn .execute ("DELETE FROM bans WHERE ucid = %s" , (row [0 ], ))
1892- except Exception as ex :
1893- self .log .exception (ex )
1878+ async with self .apool .connection () as conn :
1879+ async with conn .transaction ():
1880+ cursor = await conn .execute ("""
1881+ SELECT ucid FROM bans WHERE banned_until < (NOW() AT TIME ZONE 'utc')
1882+ """ )
1883+ rows = await cursor .fetchall ()
1884+ for row in rows :
1885+ for server in self .bot .servers .values ():
1886+ if server .status not in [Status .PAUSED , Status .RUNNING , Status .STOPPED ]:
1887+ continue
1888+ await server .send_to_dcs ({
1889+ "command" : "unban" ,
1890+ "ucid" : row [0 ]
1891+ })
1892+ # delete unbanned accounts from the database
1893+ await conn .execute ("DELETE FROM bans WHERE ucid = %s" , (row [0 ], ))
18941894
18951895 @check_for_unban .before_loop
18961896 async def before_check_unban (self ):
0 commit comments