modified: bot.py

This commit is contained in:
SimolZimol
2025-08-29 17:32:18 +02:00
parent 6c3e2d44af
commit 0debc03ec8

26
bot.py
View File

@@ -2524,7 +2524,7 @@ async def speech_to_text(ctx, *, audio_attachment: discord.Attachment = None):
# Helper function for sending responses # Helper function for sending responses
async def send_response(content=None, embed=None, ephemeral=False): async def send_response(content=None, embed=None, ephemeral=False):
try: try:
if is_slash_command: if is_slash_command and hasattr(ctx, 'followup'):
if embed: if embed:
await ctx.followup.send(embed=embed, ephemeral=ephemeral) await ctx.followup.send(embed=embed, ephemeral=ephemeral)
else: else:
@@ -2535,11 +2535,15 @@ async def speech_to_text(ctx, *, audio_attachment: discord.Attachment = None):
else: else:
await ctx.send(content) await ctx.send(content)
except Exception as e: except Exception as e:
logger.error(f"Error sending response: {e}") logger.error(f"Error sending response in speech_to_text: {e}")
# Fallback to regular send if followup fails
try: try:
await ctx.send(f"Error: {e}") if embed:
except: await ctx.send(embed=embed)
pass else:
await ctx.send(content)
except Exception as fallback_error:
logger.error(f"Fallback send also failed: {fallback_error}")
try: try:
# Get attachment (either from parameter or message) # Get attachment (either from parameter or message)
@@ -2745,7 +2749,7 @@ async def live_speech(ctx, duration: int = 10):
# Helper function for sending responses # Helper function for sending responses
async def send_response(content=None, embed=None, ephemeral=False): async def send_response(content=None, embed=None, ephemeral=False):
try: try:
if is_slash_command: if is_slash_command and hasattr(ctx, 'followup'):
if embed: if embed:
await ctx.followup.send(embed=embed, ephemeral=ephemeral) await ctx.followup.send(embed=embed, ephemeral=ephemeral)
else: else:
@@ -2756,7 +2760,15 @@ async def live_speech(ctx, duration: int = 10):
else: else:
await ctx.send(content) await ctx.send(content)
except Exception as e: except Exception as e:
logger.error(f"Error sending response: {e}") logger.error(f"Error sending response in live_speech: {e}")
# Fallback to regular send if followup fails
try:
if embed:
await ctx.send(embed=embed)
else:
await ctx.send(content)
except Exception as fallback_error:
logger.error(f"Fallback send also failed: {fallback_error}")
try: try:
# Validate duration # Validate duration