From b88ddd79267fd1a9c4406b81a729e04f514cbcd6 Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Mon, 24 Feb 2020 19:45:14 -0800 Subject: HelpChannels: compare contents to confirm message is a dormant message * Add a new function to check if a message is a dormant message --- bot/cogs/help_channels.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index 6c4c6c50e..010acfb34 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -267,6 +267,15 @@ class HelpChannels(Scheduler, commands.Cog): log.info("Cog is ready!") self.ready.set() + @staticmethod + def is_dormant_message(message: t.Optional[discord.Message]) -> bool: + """Return True if the contents of the `message` match `DORMANT_MSG`.""" + if not message or not message.embeds: + return False + + embed = message.embeds[0] + return embed.description.strip() == DORMANT_MSG.strip() + async def move_idle_channel(self, channel: discord.TextChannel) -> None: """ Make the `channel` dormant if idle or schedule the move if still active. @@ -384,7 +393,7 @@ class HelpChannels(Scheduler, commands.Cog): embed = discord.Embed(description=AVAILABLE_MSG) msg = await self.get_last_message(channel) - if msg: + if self.is_dormant_message(msg): log.trace(f"Found dormant message {msg.id} in {channel_info}; editing it.") await msg.edit(embed=embed) else: -- cgit v1.2.3