From 4ca04f60c122f534700e2a350bcbafd2471b96e4 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Sat, 26 Nov 2022 15:20:14 +0400 Subject: 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 --- bot/exts/help_channels/_channel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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", -- cgit v1.2.3