Repository: python-discord/bot

Issue:
PIn the opening message in help  channel for the session duration
Following the discussion that happened in [meta today](https://ptb.discordapp.com/channels/267624335836053506/429409067623251969/727504311638294582) I would like to suggest a new feature to the bot: make it pin the first message sent in the newly opened help session, and, of course, un-pin it when the help channel is closed.
Reasoning: some help session tend to drag out for longer time and thus to have lots of messages. This makes it very hard for anyone who's willing to to help but has not been following the discussion from the start like [here](https://ptb.discordapp.com/channels/267624335836053506/696348850981699624/727507952281452576) : having the message pinned to the channel would provide with the fast and easy way to look up the original question. 


Discussion:
When this is gonna be approved, then I'd like to do this.
Approved, go for it @ks129!
I forgot to mention that I would not mind to try it myself, but I think it's better that someone who knows bot internals already do it, as I never touched it, so with my workload it can take time :) 

Resolving patch:
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -102,6 +102,10 @@ class HelpChannels(commands.Cog):
     # RedisCache[discord.TextChannel.id, UtcPosixTimestamp]
     claim_times = RedisCache()
 
+    # This cache maps a help channel to original question message in same channel.
+    # RedisCache[discord.TextChannel.id, discord.Message.id]
+    question_messages = RedisCache()
+
     def __init__(self, bot: Bot):
         self.bot = bot
         self.scheduler = Scheduler(self.__class__.__name__)
@@ -539,6 +543,18 @@ async def move_to_dormant(self, channel: discord.TextChannel, caller: str) -> No
 
         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(
@@ -680,6 +696,14 @@ async def on_message(self, message: discord.Message) -> None:
             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.")
+            else:
+                await self.question_messages.set(channel.id, message.id)
+
             # Add user with channel for dormant check.
             await self.help_channel_claimants.set(channel.id, message.author.id)
 


Test patch: