fix(meme): improve exception handling and traceback reporting 🐛
Updated the exception handling in the meme command to include traceback details in the response. This change helps in diagnosing issues more effectively by providing the full traceback as a file attachment. *Generated by Github Copilot*
This commit is contained in:
+9
-3
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import traceback
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import httpx
|
import httpx
|
||||||
@@ -53,13 +54,18 @@ async def meme(interaction: discord.Interaction, prompt: str):
|
|||||||
)
|
)
|
||||||
await interaction.followup.send(embed=embed)
|
await interaction.followup.send(embed=embed)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception:
|
||||||
|
exception_traceback = traceback.format_exc()
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Exception",
|
title="Exception",
|
||||||
description=str(e),
|
description="See attached exception traceback",
|
||||||
color=0xFF0000,
|
color=0xFF0000,
|
||||||
)
|
)
|
||||||
await interaction.followup.send(embed=embed)
|
# Send error details as a file attachment to bypass character limits
|
||||||
|
error_file = discord.File(
|
||||||
|
fp=bytes(exception_traceback, "utf-8"), filename="exception_traceback.txt"
|
||||||
|
)
|
||||||
|
await interaction.followup.send(embed=embed, file=error_file)
|
||||||
|
|
||||||
|
|
||||||
client.run(os.getenv("DISCORD_TOKEN"))
|
client.run(os.getenv("DISCORD_TOKEN"))
|
||||||
|
|||||||
Reference in New Issue
Block a user