aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/cogs/help_channels.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index 692bb234c..e73bbdae5 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -420,6 +420,12 @@ class HelpChannels(Scheduler, commands.Cog):
embed = message.embeds[0]
return message.author == self.bot.user and embed.description.strip() == DORMANT_MSG.strip()
+ @staticmethod
+ def is_in_category(channel: discord.TextChannel, category_id: int) -> bool:
+ """Return True if `channel` is within a category with `category_id`."""
+ actual_category = getattr(channel, "category", None)
+ return actual_category is not None and actual_category.id == category_id
+
async def move_idle_channel(self, channel: discord.TextChannel, has_task: bool = True) -> None:
"""
Make the `channel` dormant if idle or schedule the move if still active.
@@ -581,7 +587,7 @@ class HelpChannels(Scheduler, commands.Cog):
return # Ignore messages sent by bots.
channel = message.channel
- if channel.category and channel.category.id != constants.Categories.help_available:
+ if not self.is_in_category(channel, constants.Categories.help_available):
return # Ignore messages outside the Available category.
log.trace("Waiting for the cog to be ready before processing messages.")
@@ -591,7 +597,7 @@ class HelpChannels(Scheduler, commands.Cog):
async with self.on_message_lock:
log.trace(f"on_message lock acquired for {message.id}.")
- if channel.category and channel.category.id != constants.Categories.help_available:
+ if not self.is_in_category(channel, constants.Categories.help_available):
log.debug(
f"Message {message.id} will not make #{channel} ({channel.id}) in-use "
f"because another message in the channel already triggered that."