diff options
| -rw-r--r-- | bot/cogs/help_channels.py | 21 | 
1 files changed, 12 insertions, 9 deletions
| diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index ed1f7c55e..554fdc55e 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -440,11 +440,18 @@ class HelpChannels(Scheduler, commands.Cog):      def is_dormant_message(self, message: t.Optional[discord.Message]) -> bool:          """Return True if the contents of the `message` match `DORMANT_MSG`.""" -        if not message or not message.embeds: +        if not message: +            return False + +        return self.embed_description_match(message, DORMANT_MSG) + +    def embed_description_match(self, message: discord.Message, text: str) -> bool: +        """Return `True` if `message` embed description match with `text`.""" +        if not message.embeds:              return False          embed = message.embeds[0] -        return message.author == self.bot.user and embed.description.strip() == DORMANT_MSG.strip() +        return message.author == self.bot.user and embed.description.strip() == text.strip()      @staticmethod      def is_in_category(channel: discord.TextChannel, category_id: int) -> bool: @@ -722,7 +729,7 @@ class HelpChannels(Scheduler, commands.Cog):          """          Reschedule an in-use channel to become dormant sooner if the channel is empty. -        The new time for the dormant task is configured with `HelpChannels.deleted_idle_minutes`.  +        The new time for the dormant task is configured with `HelpChannels.deleted_idle_minutes`.          """          if not self.is_in_category(msg.channel, constants.Categories.help_in_use) or not self.is_empty(msg.channel):              return @@ -738,14 +745,10 @@ class HelpChannels(Scheduler, commands.Cog):      async def is_empty(self, channel: discord.TextChannel) -> bool:          """Return True if the most recent message in `channel` is the bot's `AVAILABLE_MSG`."""          msg = await self.get_last_message(channel) -        if not msg or not msg.author.bot or not msg.embeds: +        if not msg:              return False -        embed = msg.embeds[0] -        if embed.description == AVAILABLE_MSG: -            return True -        else: -            return False +        return self.embed_description_match(msg, AVAILABLE_MSG)      async def reset_send_permissions(self) -> None:          """Reset send permissions in the Available category for claimants.""" | 
