diff options
author | 2022-11-26 15:20:14 +0400 | |
---|---|---|
committer | 2022-11-26 15:22:50 +0400 | |
commit | 4ca04f60c122f534700e2a350bcbafd2471b96e4 (patch) | |
tree | d480fd30d46a5383b7792c78e20878f6853925ba | |
parent | Check If Thread Is Closed In Pagination (diff) |
Handle Images As Starter Messages
In the case of an image or other media as the starter message, the
formatted message in the help DM will be empty, which is invalid for the
embed. We populate the field with some more useful text in this case.
Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r-- | bot/exts/help_channels/_channel.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 04c2cc454..b9a79a476 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -92,7 +92,11 @@ async def send_opened_post_dm(thread: discord.Thread) -> None: log.warning(f"Could not fetch message for thread {thread.id}") return - formatted_message = textwrap.shorten(message.content, width=100, placeholder="...") + formatted_message = textwrap.shorten(message.content, width=100, placeholder="...").strip() + if formatted_message is None: + # This most likely means the initial message is only an image or similar + formatted_message = "No text content." + embed.add_field(name="Your message", value=formatted_message, inline=False) embed.add_field( name="Conversation", |