modified: bot.py
This commit is contained in:
57
bot.py
57
bot.py
@@ -5014,7 +5014,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
|
|
||||||
# Send response based on silent mode
|
# Send response based on silent mode
|
||||||
if silent:
|
if silent:
|
||||||
# Silent mode: ephemeral response to moderator only
|
# Silent mode: create special silent embed and send as ephemeral
|
||||||
silent_embed = discord.Embed(
|
silent_embed = discord.Embed(
|
||||||
title="🔇 Silent Warning Issued",
|
title="🔇 Silent Warning Issued",
|
||||||
description=f"{user.mention} has been warned silently.",
|
description=f"{user.mention} has been warned silently.",
|
||||||
@@ -5032,51 +5032,20 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
silent_embed.set_footer(text=f"Silent Mode • User ID: {user.id}")
|
silent_embed.set_footer(text=f"Silent Mode • User ID: {user.id}")
|
||||||
silent_embed.set_thumbnail(url=user.display_avatar.url)
|
silent_embed.set_thumbnail(url=user.display_avatar.url)
|
||||||
|
|
||||||
# Send ephemeral response - use followup since we deferred
|
# Send as ephemeral
|
||||||
try:
|
if is_slash_command:
|
||||||
if is_slash_command:
|
if hasattr(ctx, 'followup') and ctx.followup is not None:
|
||||||
# Since we deferred with ephemeral=silent, use followup
|
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||||
# Make sure followup is available and properly initialized
|
logger.info(f"Silent warning sent via ctx.followup.send (ephemeral)")
|
||||||
if hasattr(ctx, 'followup') and ctx.followup is not None:
|
elif hasattr(ctx, 'interaction') and ctx.interaction:
|
||||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
await ctx.interaction.followup.send(embed=silent_embed, ephemeral=True)
|
||||||
logger.info(f"Silent warning sent via ctx.followup.send (ephemeral)")
|
logger.info(f"Silent warning sent via ctx.interaction.followup.send (ephemeral)")
|
||||||
elif hasattr(ctx, 'interaction') and ctx.interaction:
|
|
||||||
# Direct interaction followup as fallback
|
|
||||||
await ctx.interaction.followup.send(embed=silent_embed, ephemeral=True)
|
|
||||||
logger.info(f"Silent warning sent via ctx.interaction.followup.send (ephemeral)")
|
|
||||||
else:
|
|
||||||
logger.error(f"Silent warning failed: No followup available - ctx.followup: {getattr(ctx, 'followup', None)}")
|
|
||||||
raise Exception("No followup available after defer")
|
|
||||||
else:
|
else:
|
||||||
# For prefix commands, we can't do true ephemeral, so log error instead
|
logger.error(f"Silent warning failed: No followup available")
|
||||||
logger.error(f"Silent warning attempted with prefix command - not supported")
|
else:
|
||||||
raise Exception("Silent mode only works with slash commands")
|
logger.error(f"Silent warning attempted with prefix command - not supported")
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error sending silent warning response: {e}")
|
|
||||||
# Send error to mod log instead of fallback message
|
|
||||||
try:
|
|
||||||
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),
|
|
||||||
"Command Type": "Slash" if is_slash_command else "Prefix",
|
|
||||||
"Fallback": "User received DM notification normally"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
except Exception as log_error:
|
|
||||||
logger.error(f"Failed to log silent warning error: {log_error}")
|
|
||||||
|
|
||||||
# Silent mode is complete - exit here to prevent normal logging/responses
|
|
||||||
return
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Normal mode: public response
|
# Normal mode: send public response
|
||||||
await send_response(embed=embed)
|
await send_response(embed=embed)
|
||||||
|
|
||||||
# Log the warning action
|
# Log the warning action
|
||||||
|
|||||||
Reference in New Issue
Block a user