Repository: python-discord/bot

Issue:
DM when opening help channel
## Use case/rationale
Sometimes, users don't remember which help channel is theirs. Other times, they simply wanna look back at the old help channel threads and review what was said.

## Proposed solution
DM users with an embed when opening a new help channel. The following info would be included:

1. Help channel name
2. Preview of first message sent
3. "Jump to message" link

(1) Would allow them to quickly look up the channel name or remind themselves what channel was claimed, without necessarily going there.

(2) Let's them quickly remember what issue was discussed in the help channel, after the help session is over

(3) Allows the user to easily navigate to the beginning of the thread, both during a help session and when it's done.


Discussion:
This would have a lot in common with the current SeasonalBot bookmark command:
![image](https://user-images.githubusercontent.com/65498475/94207381-c4af6f00-fec7-11ea-8054-c6b318537bbb.jpeg)
What recourse will someone have if they do _not_ want to receive these messages? A significant number of people have expressed that they have trouble remembering the channel names (more so those giving help than those receiving it), but would they all be willing to accept DMs as a solution?

Personally, I'd write down the name if I had trouble remembering; I don't think it's too much to ask of others to do the same. Furthermore, there's the search feature in Discord. I find it hard to believe someone will be incapable of finding their own question through that (i.e. that their memory would be so bad they can't even remember what they asked).

I'm not too keen on adding more features to the system. We should strive to keep it simple, both internally and externally.
I think you're right about that. Maybe adding a command like `!claimed` could be a more suitable solution. The name of ot will have to be worked on, but I think the idea of a command like it would be nice. You could either check who claimed a certain help channel or run it without arguments to see what channel you've claimed.
I think Leterax made a really good point in `#meta`, what if we send the DM only when you get your first answer? The obvious upside is that you'll know when you'd have a potential answer, and the less obvious one is that it'll reduce the number of API calls made when opening a help channel. 
@Akarys42 That would mean that people are reminded to go back to the channel and engage on a message, which could be a good thing. It also gives them a place to see the conversations that were at least not totally ignored.

On the flip side, I think it's odd not giving the user a complete log of help channel activity in their DMs. What if they wanna find back to a question that wasn't answered? What if they wanna update their question but has left the channel?

Taking all of this into account, it seems a bit inconsistent and unintuitive to send a DM only on the first *response*. Maybe we could send an additional message when a user responds, if you make a great case for it, but I'm not a huge fan of sending the DM only on the first response. I think either sending it from the start or not at all would be best.
Maybe we could send a message if their help channel was closed without being answered, with a link to the "asking good questions" page and saying that they are free to open a new channel after the cooldown wears off? I think this would be even better. 
I like the idea of sending it on the first reply. It's quick and easy to navigate to again if you lost your help channel. Having a `!claimed` command kind of defeats the purpose for me, since it doesn't provide that "quick" feel anymore. I think a simple solution to what @/MarkKoz said would just make it opt-in / opt-out.
I'm not sure that we should be worrying at people being angry for us when we DM them that they've opened a help channel.

If it was an unprompted DM, sure, we could think into whether it's worth the annoyance or not, but they are using our system and I think that the many people who will benefit from being able to jump back to help sessions greatly outweighs those who may be slightly agitated by DMs (and even then, they can disable them and things still work fine).

If we truly want to keep things simple, sending a DM is much less complex than relaying help channel claimants through a command, and does not rely on the user having knowledge of our commands. This should be an active system, not a passive one.
I’ll give this a shot!

Resolving patch:
diff --git a/bot/constants.py b/bot/constants.py
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -326,6 +326,7 @@ class Icons(metaclass=YAMLGetter):
     filtering: str
 
     green_checkmark: str
+    green_questionmark: str
     guild_update: str
 
     hash_blurple: str
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py
--- a/bot/exts/help_channels/_cog.py
+++ b/bot/exts/help_channels/_cog.py
@@ -102,6 +102,7 @@ async def claim_channel(self, message: discord.Message) -> None:
         await _cooldown.revoke_send_permissions(message.author, self.scheduler)
 
         await _message.pin(message)
+        await _message.dm_on_open(message)
 
         # Add user with channel for dormant check.
         await _caches.claimants.set(message.channel.id, message.author.id)
diff --git a/bot/exts/help_channels/_message.py b/bot/exts/help_channels/_message.py
--- a/bot/exts/help_channels/_message.py
+++ b/bot/exts/help_channels/_message.py
@@ -1,4 +1,5 @@
 import logging
+import textwrap
 import typing as t
 from datetime import datetime
 
@@ -92,6 +93,40 @@ async def is_empty(channel: discord.TextChannel) -> bool:
     return False
 
 
+async def dm_on_open(message: discord.Message) -> None:
+    """
+    DM claimant with a link to the claimed channel's first message, with a 100 letter preview of the message.
+
+    Does nothing if the user has DMs disabled.
+    """
+    embed = discord.Embed(
+        title="Help channel opened",
+        description=f"You claimed {message.channel.mention}.",
+        colour=bot.constants.Colours.bright_green,
+        timestamp=message.created_at,
+    )
+
+    embed.set_thumbnail(url=constants.Icons.green_questionmark)
+    embed.add_field(
+        name="Your message",
+        value=textwrap.shorten(message.content, width=100, placeholder="..."),
+        inline=False,
+    )
+    embed.add_field(
+        name="Conversation",
+        value=f"[Jump to message!]({message.jump_url})",
+        inline=False,
+    )
+
+    try:
+        await message.author.send(embed=embed)
+        log.trace(f"Sent DM to {message.author.id} after claiming help channel.")
+    except discord.errors.Forbidden:
+        log.trace(
+            f"Ignoring to send DM to {message.author.id} after claiming help channel: DMs disabled."
+        )
+
+
 async def notify(channel: discord.TextChannel, last_notification: t.Optional[datetime]) -> t.Optional[datetime]:
     """
     Send a message in `channel` notifying about a lack of available help channels.


Test patch: