modified: bot.py
This commit is contained in:
56
bot.py
56
bot.py
@@ -5031,10 +5031,11 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
||||
# Send ephemeral response - force it to be ephemeral
|
||||
try:
|
||||
if is_slash_command:
|
||||
if hasattr(ctx, 'followup') and ctx.followup:
|
||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||
elif hasattr(ctx, 'response') and not ctx.response.is_done():
|
||||
# For slash commands, use response.send_message directly for ephemeral
|
||||
if hasattr(ctx, 'response') and not ctx.response.is_done():
|
||||
await ctx.response.send_message(embed=silent_embed, ephemeral=True)
|
||||
elif hasattr(ctx, 'followup') and ctx.followup:
|
||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||
else:
|
||||
# If somehow we get here, try a fallback
|
||||
await ctx.send(embed=silent_embed, delete_after=30)
|
||||
@@ -5048,11 +5049,23 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"Error sending silent warning response: {e}")
|
||||
# Last resort fallback
|
||||
# Send error to mod log instead of fallback message
|
||||
try:
|
||||
await ctx.send(f"⚠️ {user.mention} has been warned silently. Check DMs for details.", delete_after=10)
|
||||
except:
|
||||
pass
|
||||
await log_moderation_action(
|
||||
guild=ctx.guild,
|
||||
action_type="warning_error",
|
||||
moderator=ctx.author,
|
||||
target_user=user,
|
||||
reason=f"Silent warning issued but ephemeral response failed: {str(e)}",
|
||||
additional_info={
|
||||
"Original Reason": reason,
|
||||
"Warning ID": str(warning_id) if warning_id else "N/A",
|
||||
"Error Details": str(e),
|
||||
"Fallback": "User received DM notification normally"
|
||||
}
|
||||
)
|
||||
except Exception as log_error:
|
||||
logger.error(f"Failed to log silent warning error: {log_error}")
|
||||
|
||||
else:
|
||||
# Normal mode: public response
|
||||
@@ -6615,10 +6628,11 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
|
||||
# Send ephemeral response - force it to be ephemeral
|
||||
try:
|
||||
if is_slash_command:
|
||||
if hasattr(ctx, 'followup') and ctx.followup:
|
||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||
elif hasattr(ctx, 'response') and not ctx.response.is_done():
|
||||
# For slash commands, use response.send_message directly for ephemeral
|
||||
if hasattr(ctx, 'response') and not ctx.response.is_done():
|
||||
await ctx.response.send_message(embed=silent_embed, ephemeral=True)
|
||||
elif hasattr(ctx, 'followup') and ctx.followup:
|
||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||
else:
|
||||
# If somehow we get here, try a fallback
|
||||
await ctx.send(embed=silent_embed, delete_after=30)
|
||||
@@ -6632,11 +6646,25 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"Error sending silent mute response: {e}")
|
||||
# Last resort fallback
|
||||
# Send error to mod log instead of fallback message
|
||||
try:
|
||||
await ctx.send(f"🔇 {user.mention} has been muted silently for {duration}. Check DMs for details.", delete_after=10)
|
||||
except:
|
||||
pass
|
||||
await log_moderation_action(
|
||||
guild=ctx.guild,
|
||||
action_type="mute_error",
|
||||
moderator=ctx.author,
|
||||
target_user=user,
|
||||
reason=f"Silent mute issued but ephemeral response failed: {str(e)}",
|
||||
duration=duration,
|
||||
additional_info={
|
||||
"Original Reason": reason,
|
||||
"Mute ID": str(mute_id) if mute_id else "N/A",
|
||||
"Duration": duration,
|
||||
"Error Details": str(e),
|
||||
"Fallback": "User received DM notification normally"
|
||||
}
|
||||
)
|
||||
except Exception as log_error:
|
||||
logger.error(f"Failed to log silent mute error: {log_error}")
|
||||
|
||||
else:
|
||||
# Normal mode: public response
|
||||
|
||||
Reference in New Issue
Block a user