diff options
author | 2021-02-23 19:24:18 +0300 | |
---|---|---|
committer | 2021-02-23 19:24:18 +0300 | |
commit | d71ac9f6e240ffd2d4195d9dbbf5740a0c2413a1 (patch) | |
tree | 4ddc96036b326846a10e15e6c99b4e869d0b5d98 | |
parent | Merge pull request #1429 from python-discord/dm-on-open-help-channel (diff) |
Fixes Problems With Help Channel DM
Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r-- | bot/exts/help_channels/_cog.py | 5 | ||||
-rw-r--r-- | bot/exts/help_channels/_message.py | 8 |
2 files changed, 7 insertions, 6 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index a18ddc900..6abf99810 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -102,7 +102,10 @@ class HelpChannels(commands.Cog): await _cooldown.revoke_send_permissions(message.author, self.scheduler) await _message.pin(message) - await _message.dm_on_open(message) + try: + await _message.dm_on_open(message) + except Exception as e: + log.warning("Error occurred while sending DM:", exc_info=e) # 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 index 4113e51c5..36388f9bd 100644 --- a/bot/exts/help_channels/_message.py +++ b/bot/exts/help_channels/_message.py @@ -107,11 +107,9 @@ async def dm_on_open(message: discord.Message) -> None: ) embed.set_thumbnail(url=constants.Icons.green_questionmark) - embed.add_field( - name="Your message", - value=textwrap.shorten(message.content, width=100, placeholder="..."), - inline=False, - ) + formatted_message = textwrap.shorten(message.content, width=100, placeholder="...") + if formatted_message: + embed.add_field(name="Your message", value=formatted_message, inline=False) embed.add_field( name="Conversation", value=f"[Jump to message!]({message.jump_url})", |