aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-08-04 12:32:44 -0700
committerGravatar MarkKoz <[email protected]>2020-08-04 12:32:44 -0700
commitf553785858e70ff78c6fef5a5a4fa3e75c09a55e (patch)
tree3b66c0690a6fef54d7a61dfd46de1037de5e1c27
parentRevert "Disabled burst_shared filter temporarily" (diff)
HelpChannels: move unpinning to separate function
-rw-r--r--bot/cogs/help_channels.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index 1be980472..61e8d4384 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -551,18 +551,6 @@ class HelpChannels(commands.Cog):
A caller argument is provided for metrics.
"""
- msg_id = await self.question_messages.pop(channel.id)
-
- try:
- await self.bot.http.unpin_message(channel.id, msg_id)
- except discord.HTTPException as e:
- if e.code == 10008:
- log.trace(f"Message {msg_id} don't exist, can't unpin.")
- else:
- log.warn(f"Got unexpected status {e.code} when unpinning message {msg_id}: {e.text}")
- else:
- log.trace(f"Unpinned message {msg_id}.")
-
log.info(f"Moving #{channel} ({channel.id}) to the Dormant category.")
await self.move_to_bottom_position(
@@ -587,6 +575,8 @@ class HelpChannels(commands.Cog):
embed = discord.Embed(description=DORMANT_MSG)
await channel.send(embed=embed)
+ await self.unpin(channel)
+
log.trace(f"Pushing #{channel} ({channel.id}) into the channel queue.")
self.channel_queue.put_nowait(channel)
self.report_stats()
@@ -863,6 +853,20 @@ class HelpChannels(commands.Cog):
log.trace(f"Channel #{channel} ({channel_id}) retrieved.")
return channel
+ async def unpin(self, channel: discord.TextChannel) -> None:
+ """Unpin the initial question message sent in `channel`."""
+ msg_id = await self.question_messages.pop(channel.id)
+
+ try:
+ await self.bot.http.unpin_message(channel.id, msg_id)
+ except discord.HTTPException as e:
+ if e.code == 10008:
+ log.trace(f"Message {msg_id} don't exist, can't unpin.")
+ else:
+ log.warn(f"Got unexpected status {e.code} when unpinning message {msg_id}: {e.text}")
+ else:
+ log.trace(f"Unpinned message {msg_id}.")
+
async def wait_for_dormant_channel(self) -> discord.TextChannel:
"""Wait for a dormant channel to become available in the queue and return it."""
log.trace("Waiting for a dormant channel.")