From 6a435301421ddf9525ca8e97decd3ca310614e33 Mon Sep 17 00:00:00 2001 From: Conatum Date: Tue, 19 Oct 2021 20:21:57 +0300 Subject: [PATCH] fix (rooms): Harden `turnover` to deletion. Fix an issue where `TimeSlot.start()` could propagate an exception. --- bot/modules/accountability/TimeSlot.py | 17 ++++++++++++++--- bot/modules/accountability/tracker.py | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bot/modules/accountability/TimeSlot.py b/bot/modules/accountability/TimeSlot.py index 86fdcf06..b87a0df3 100644 --- a/bot/modules/accountability/TimeSlot.py +++ b/bot/modules/accountability/TimeSlot.py @@ -334,10 +334,21 @@ class TimeSlot: Update the status message, and launch the DM reminder. """ if self.channel: - await self.channel.edit(name="Accountability Study Room") - await self.channel.set_permissions(self.guild.default_role, view_channel=True, connect=False) + try: + await self.channel.edit(name="Accountability Study Room") + await self.channel.set_permissions(self.guild.default_role, view_channel=True, connect=False) + except discord.HTTPException: + pass asyncio.create_task(self.dm_reminder(delay=60)) - await self.message.edit(embed=self.status_embed) + try: + await self.message.edit(embed=self.status_embed) + except discord.NotFound: + try: + self.message = await self.lobby.send( + embed=self.status_embed + ) + except discord.HTTPException: + self.message = None async def dm_reminder(self, delay=60): """ diff --git a/bot/modules/accountability/tracker.py b/bot/modules/accountability/tracker.py index e1136b39..51713230 100644 --- a/bot/modules/accountability/tracker.py +++ b/bot/modules/accountability/tracker.py @@ -232,7 +232,8 @@ async def turnover(): # Start all the current rooms await asyncio.gather( - *(slot.start() for slot in current_slots) + *(slot.start() for slot in current_slots), + return_exceptions=True )