From 88503bc50606014c60c5c60d67840cf7e888c9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Mon, 22 Sep 2025 01:35:20 +0200 Subject: [PATCH] Add error handling for response sending in ask command --- main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 3a29014..9f3a43e 100644 --- a/main.py +++ b/main.py @@ -187,7 +187,14 @@ async def ask(interaction: discord.Interaction, text: str) -> None: discord_file = discord.File(io.BytesIO(file_content), filename="response.txt") await interaction.followup.send(f"{text}", file=discord_file) - await interaction.followup.send(response) + try: + await interaction.followup.send(response) + except discord.HTTPException as e: + e.add_note(f"Response length: {len(response)} characters.") + e.add_note(f"User input length: {len(text)} characters.") + + logger.exception("Failed to send message to channel %s", interaction.channel) + await interaction.followup.send(f"Failed to send message: {e}") def truncate_user_input(text: str) -> str: