aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2021-01-03 11:07:27 -0800
committerGravatar MarkKoz <[email protected]>2021-01-04 23:19:54 -0800
commit025edaa3e5b0774401ab83e925c830928e54e0fe (patch)
tree539111aaf975a54a96d365cec7723ad882f66bf9
parentHelpChannels: use a more accurate lock for messages (diff)
HelpChannels: await init task at the start of event listeners
It feels safer to do this since the init task moves channels to different categories and the listeners check if channels are in certain categories.
-rw-r--r--bot/exts/help_channels/_cog.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py
index 76c671641..a9ca01cdd 100644
--- a/bot/exts/help_channels/_cog.py
+++ b/bot/exts/help_channels/_cog.py
@@ -462,9 +462,10 @@ class HelpChannels(commands.Cog):
if message.author.bot:
return # Ignore messages sent by bots.
+ await self.init_task
+
if channel_utils.is_in_category(message.channel, constants.Categories.help_available):
if not _channel.is_excluded_channel(message.channel):
- await self.init_task
await self.claim_channel(message)
await self.move_to_available() # Not in a lock because it may wait indefinitely.
else:
@@ -477,15 +478,14 @@ class HelpChannels(commands.Cog):
The new time for the dormant task is configured with `HelpChannels.deleted_idle_minutes`.
"""
+ await self.init_task
+
if not channel_utils.is_in_category(msg.channel, constants.Categories.help_in_use):
return
if not await _message.is_empty(msg.channel):
return
- log.trace("Waiting for the cog to be ready before processing deleted messages.")
- await self.init_task
-
log.info(f"Claimant of #{msg.channel} ({msg.author}) deleted message, channel is empty now. Rescheduling task.")
# Cancel existing dormant task before scheduling new.