aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-08-04 13:09:20 -0700
committerGravatar MarkKoz <[email protected]>2020-08-04 13:52:03 -0700
commit4b7f19287c3d212a55276b0862f6a629269eaf92 (patch)
tree91fc189033836d11f2db9997f314d967cde89ceb
parentHelpChannels: create a generic function to handle pin errors (diff)
HelpChannels: create separate function to pin a message
-rw-r--r--bot/cogs/help_channels.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index b452cc574..d826463af 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -694,15 +694,8 @@ class HelpChannels(commands.Cog):
log.info(f"Channel #{channel} was claimed by `{message.author.id}`.")
await self.move_to_in_use(channel)
await self.revoke_send_permissions(message.author)
- # Pin message for better access and store this to cache
- try:
- await message.pin()
- except discord.NotFound:
- log.info(f"Pinning message {message.id} ({channel}) failed because message got deleted.")
- except discord.HTTPException as e:
- log.info(f"Pinning message {message.id} ({channel.id}) failed with code {e.code}", exc_info=e)
- else:
- await self.question_messages.set(channel.id, message.id)
+
+ await self.pin(message)
# Add user with channel for dormant check.
await self.help_channel_claimants.set(channel.id, message.author.id)
@@ -881,6 +874,11 @@ class HelpChannels(commands.Cog):
log.trace(f"{verb.capitalize()}ned message {msg_id} in {channel_str}.")
return True
+ async def pin(self, message: discord.Message) -> None:
+ """Pin an initial question `message` and store it in a cache."""
+ if await self.pin_wrapper(message.id, message.channel, pin=True):
+ await self.question_messages.set(message.channel.id, message.id)
+
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)