modified: bot.py

This commit is contained in:
SimolZimol
2025-11-07 20:02:13 +01:00
parent 8ba7a1bf98
commit 618819707c

46
bot.py
View File

@@ -4756,9 +4756,9 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
Note: context_range parameter only works when message_id is also provided!
"""
# Check if it's a slash command and defer if needed
# Check if it's a slash command and defer if needed (skip defer for silent mode)
is_slash_command = hasattr(ctx, 'interaction') and ctx.interaction
if is_slash_command:
if is_slash_command and not silent:
await ctx.defer()
# Helper function for sending responses
@@ -5010,7 +5010,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
# Send response based on silent mode
if silent:
# Silent mode: ephemeral response to moderator at command location
# Silent mode: ephemeral response to moderator only
silent_embed = discord.Embed(
title="🔇 Silent Warning Issued",
description=f"{user.mention} has been warned silently.",
@@ -5028,24 +5028,31 @@ 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_thumbnail(url=user.display_avatar.url)
# Force ephemeral response regardless of command type
# 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():
await ctx.response.send_message(embed=silent_embed, ephemeral=True)
else:
# Fallback for slash commands without proper response
await ctx.send(embed=silent_embed, ephemeral=True)
# If somehow we get here, try a fallback
await ctx.send(embed=silent_embed, delete_after=30)
else:
# For prefix commands, send ephemeral-like message (delete after short time)
# For prefix commands, send and delete quickly
msg = await ctx.send(embed=silent_embed)
# Auto-delete after 30 seconds for prefix commands
await asyncio.sleep(30)
try:
await msg.delete()
except:
pass
except Exception as e:
logger.error(f"Error sending silent warning response: {e}")
# Last resort fallback
try:
await ctx.send(f"⚠️ {user.mention} has been warned silently. Check DMs for details.", delete_after=10)
except:
pass
else:
# Normal mode: public response
@@ -6317,9 +6324,9 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
Note: context_range parameter only works when message_id is also provided!
"""
# Check if it's a slash command and defer if needed
# Check if it's a slash command and defer if needed (skip defer for silent mode)
is_slash_command = hasattr(ctx, 'interaction') and ctx.interaction
if is_slash_command:
if is_slash_command and not silent:
await ctx.defer()
# Helper function for sending responses
@@ -6586,7 +6593,7 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
# Send response based on silent mode
if silent:
# Silent mode: ephemeral response to moderator at command location
# Silent mode: ephemeral response to moderator only
silent_embed = discord.Embed(
title="🔇 Silent Mute Applied",
description=f"{user.mention} has been muted silently.",
@@ -6605,24 +6612,31 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
silent_embed.set_footer(text=f"Silent Mode • User ID: {user.id} | Use /viewmute {mute_id} for details")
silent_embed.set_thumbnail(url=user.display_avatar.url)
# Force ephemeral response regardless of command type
# 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():
await ctx.response.send_message(embed=silent_embed, ephemeral=True)
else:
# Fallback for slash commands without proper response
await ctx.send(embed=silent_embed, ephemeral=True)
# If somehow we get here, try a fallback
await ctx.send(embed=silent_embed, delete_after=30)
else:
# For prefix commands, send ephemeral-like message (delete after short time)
# For prefix commands, send and delete quickly
msg = await ctx.send(embed=silent_embed)
# Auto-delete after 30 seconds for prefix commands
await asyncio.sleep(30)
try:
await msg.delete()
except:
pass
except Exception as e:
logger.error(f"Error sending silent mute response: {e}")
# Last resort fallback
try:
await ctx.send(f"🔇 {user.mention} has been muted silently for {duration}. Check DMs for details.", delete_after=10)
except:
pass
else:
# Normal mode: public response