aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-24 19:45:14 -0800
committerGravatar MarkKoz <[email protected]>2020-03-22 15:54:38 -0700
commitb88ddd79267fd1a9c4406b81a729e04f514cbcd6 (patch)
treead02ec1cb6ba1f78b43e07ce1dd172596a906721
parentHelpChannels: add a function to send or edit the available message (diff)
HelpChannels: compare contents to confirm message is a dormant message
* Add a new function to check if a message is a dormant message
-rw-r--r--bot/cogs/help_channels.py11
1 files changed, 10 insertions, 1 deletions
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: