From a3f67c5361f1acb8f4aa022b7a59209c2f175412 Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Sat, 29 Feb 2020 15:45:23 -0800 Subject: HelpChannels: fix unawaited coro warning for set_permissions This was happening when attempting to schedule a task twice for a user. Because the scheduler refuses to schedule a duplicate, the coroutine is deallocated right away without being awaited (or closed explicitly by `scheduled_task`). To fix, any existing task is cancelled before scheduling. This also means if somehow a user bypasses the lack of permissions, their cooldown will be updated. However, it probably doesn't make a difference as if they can bypass once, they likely can bypass again. --- bot/cogs/help_channels.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index d6031d7ff..6725efb72 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -556,6 +556,10 @@ class HelpChannels(Scheduler, commands.Cog): await self.available_category.set_permissions(member, send_messages=False) + # Cancel the existing task, if any. + # Would mean the user somehow bypassed the lack of permissions (e.g. user is guild owner). + self.cancel_task(member.id, ignore_missing=True) + timeout = constants.HelpChannels.claim_minutes * 60 callback = self.available_category.set_permissions(member, send_messages=None) -- cgit v1.2.3