aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-15 21:21:51 -0800
committerGravatar MarkKoz <[email protected]>2020-02-15 21:21:51 -0800
commit6edae6cda82add4d0bf538e916ce571432f83ab1 (patch)
tree32329817f4b40526e8333ddbaee14374f138c31c
parentScheduler: cancel the task in the callback (diff)
Moderation: avoid prematurely cancelling deactivation task
Because deactivate_infraction() explicitly cancels the scheduled task, it now runs in a separate task to avoid prematurely cancelling itself.
-rw-r--r--bot/cogs/moderation/scheduler.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/bot/cogs/moderation/scheduler.py b/bot/cogs/moderation/scheduler.py
index 62b040d1f..7d401c7ff 100644
--- a/bot/cogs/moderation/scheduler.py
+++ b/bot/cogs/moderation/scheduler.py
@@ -415,4 +415,6 @@ class InfractionScheduler(Scheduler):
expiry = dateutil.parser.isoparse(infraction["expires_at"]).replace(tzinfo=None)
await time.wait_until(expiry)
- await self.deactivate_infraction(infraction)
+ # Because deactivate_infraction() explicitly cancels this scheduled task, it runs in
+ # a separate task to avoid prematurely cancelling itself.
+ self.bot.loop.create_task(self.deactivate_infraction(infraction))