(timers): Destroy timers when channel is gone.

This commit is contained in:
2022-01-14 18:30:10 +02:00
parent e220ab9dfd
commit b124cf8e1e

View File

@@ -327,7 +327,7 @@ class Timer:
Remove the timer. Remove the timer.
""" """
# Remove timer from cache # Remove timer from cache
self.timers.pop(self.channelid) self.timers.pop(self.channelid, None)
# Cancel the loop # Cancel the loop
if self._run_task: if self._run_task:
@@ -372,6 +372,11 @@ class Timer:
except asyncio.CancelledError: except asyncio.CancelledError:
break 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(): if self._state.end < utc_now():
asyncio.create_task(self.notify_change_stage(self._state, self.current_stage)) asyncio.create_task(self.notify_change_stage(self._state, self.current_stage))
else: else: