aboutsummaryrefslogtreecommitdiffstats
path: root/bot/cogs/reminders.py
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-08-04 17:31:50 -0700
committerGravatar MarkKoz <[email protected]>2020-08-04 17:31:50 -0700
commit3e5558a8ccf79dfeb3efbb63d48d807ba67c8377 (patch)
treea9da202ab939dbd72656c865c368838fe25e988d /bot/cogs/reminders.py
parentRevert "Disabled burst_shared filter temporarily" (diff)
Cancel scheduled tasks when cogs unload
When cogs reload, they used new Scheduler instances, which aren't aware of previously scheduled tasks. This led to duplicate scheduled tasks when cogs re-scheduled tasks upon initialisation. Fixes #1080 Fixes BOT-7H
Diffstat (limited to '')
-rw-r--r--bot/cogs/reminders.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/bot/cogs/reminders.py b/bot/cogs/reminders.py
index b5998cc0e..670493bcf 100644
--- a/bot/cogs/reminders.py
+++ b/bot/cogs/reminders.py
@@ -37,6 +37,10 @@ class Reminders(Cog):
self.bot.loop.create_task(self.reschedule_reminders())
+ def cog_unload(self) -> None:
+ """Cancel scheduled tasks."""
+ self.scheduler.cancel_all()
+
async def reschedule_reminders(self) -> None:
"""Get all current reminders from the API and reschedule them."""
await self.bot.wait_until_guild_available()