From b124cf8e1e7894243c2c4906b3071cd57c29b484 Mon Sep 17 00:00:00 2001 From: Conatum Date: Fri, 14 Jan 2022 18:30:10 +0200 Subject: [PATCH] (timers): Destroy timers when channel is gone. --- bot/modules/study/timers/Timer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bot/modules/study/timers/Timer.py b/bot/modules/study/timers/Timer.py index bef4aa72..88a15f4f 100644 --- a/bot/modules/study/timers/Timer.py +++ b/bot/modules/study/timers/Timer.py @@ -327,7 +327,7 @@ class Timer: Remove the timer. """ # Remove timer from cache - self.timers.pop(self.channelid) + self.timers.pop(self.channelid, None) # Cancel the loop if self._run_task: @@ -372,6 +372,11 @@ class Timer: except asyncio.CancelledError: break + # Destroy the timer if our voice channel no longer exists + if not self.channel: + await self.destroy() + break + if self._state.end < utc_now(): asyncio.create_task(self.notify_change_stage(self._state, self.current_stage)) else: