diff options
| author | 2020-02-29 15:45:23 -0800 | |
|---|---|---|
| committer | 2020-03-22 15:54:44 -0700 | |
| commit | a3f67c5361f1acb8f4aa022b7a59209c2f175412 (patch) | |
| tree | e64adb11983baf5768319273069fa8a33462b40d | |
| parent | HelpChannels: fix unawaited coro warning (diff) | |
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.
| -rw-r--r-- | bot/cogs/help_channels.py | 4 |
1 files changed, 4 insertions, 0 deletions
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) |