(timers): Destroy timers when channel is gone.
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user