From 89b345c61b7d2d227b42def2a4ad6ca33b407ec8 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Sun, 25 Sep 2022 17:22:02 +0200 Subject: [PATCH] Improve error message handling --- didier/data/embeds/error_embed.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/didier/data/embeds/error_embed.py b/didier/data/embeds/error_embed.py index 70bc2d3..ea03bfe 100644 --- a/didier/data/embeds/error_embed.py +++ b/didier/data/embeds/error_embed.py @@ -20,7 +20,7 @@ def _get_traceback(exception: Exception) -> str: break # Escape Discord Markdown formatting - error_string += line.replace(r"*", r"\*").replace(r"_", r"\_") + error_string += line if line.strip(): error_string += "\n" @@ -45,7 +45,12 @@ def create_error_embed(ctx: Optional[commands.Context], exception: Exception) -> invocation = f"{ctx.author.display_name} in {origin}" - embed.add_field(name="Command", value=f"{ctx.message.content}", inline=True) + if ctx.interaction is not None and ctx.interaction.command is not None: + command = ctx.interaction.command.name + else: + command = ctx.message.content or "N/A" + + embed.add_field(name="Command", value=command, inline=True) embed.add_field(name="Context", value=invocation, inline=True) if message: