modified: bot.py
This commit is contained in:
82
bot.py
82
bot.py
@@ -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!
|
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
|
is_slash_command = hasattr(ctx, 'interaction') and ctx.interaction
|
||||||
if is_slash_command:
|
if is_slash_command and not silent:
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
|
|
||||||
# Helper function for sending responses
|
# 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
|
# Send response based on silent mode
|
||||||
if silent:
|
if silent:
|
||||||
# Silent mode: ephemeral response to moderator at command location
|
# Silent mode: ephemeral response to moderator only
|
||||||
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.",
|
||||||
@@ -5028,22 +5028,29 @@ 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)
|
||||||
|
|
||||||
# Force ephemeral response regardless of command type
|
# Send ephemeral response - force it to be ephemeral
|
||||||
if is_slash_command:
|
try:
|
||||||
if hasattr(ctx, 'followup') and ctx.followup:
|
if is_slash_command:
|
||||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
if hasattr(ctx, 'followup') and ctx.followup:
|
||||||
elif hasattr(ctx, 'response') and not ctx.response.is_done():
|
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||||
await ctx.response.send_message(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:
|
||||||
|
# If somehow we get here, try a fallback
|
||||||
|
await ctx.send(embed=silent_embed, delete_after=30)
|
||||||
else:
|
else:
|
||||||
# Fallback for slash commands without proper response
|
# For prefix commands, send and delete quickly
|
||||||
await ctx.send(embed=silent_embed, ephemeral=True)
|
msg = await ctx.send(embed=silent_embed)
|
||||||
else:
|
await asyncio.sleep(30)
|
||||||
# For prefix commands, send ephemeral-like message (delete after short time)
|
try:
|
||||||
msg = await ctx.send(embed=silent_embed)
|
await msg.delete()
|
||||||
# Auto-delete after 30 seconds for prefix commands
|
except:
|
||||||
await asyncio.sleep(30)
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error sending silent warning response: {e}")
|
||||||
|
# Last resort fallback
|
||||||
try:
|
try:
|
||||||
await msg.delete()
|
await ctx.send(f"⚠️ {user.mention} has been warned silently. Check DMs for details.", delete_after=10)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -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!
|
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
|
is_slash_command = hasattr(ctx, 'interaction') and ctx.interaction
|
||||||
if is_slash_command:
|
if is_slash_command and not silent:
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
|
|
||||||
# Helper function for sending responses
|
# 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
|
# Send response based on silent mode
|
||||||
if silent:
|
if silent:
|
||||||
# Silent mode: ephemeral response to moderator at command location
|
# Silent mode: ephemeral response to moderator only
|
||||||
silent_embed = discord.Embed(
|
silent_embed = discord.Embed(
|
||||||
title="🔇 Silent Mute Applied",
|
title="🔇 Silent Mute Applied",
|
||||||
description=f"{user.mention} has been muted silently.",
|
description=f"{user.mention} has been muted silently.",
|
||||||
@@ -6605,22 +6612,29 @@ 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_footer(text=f"Silent Mode • User ID: {user.id} | Use /viewmute {mute_id} for details")
|
||||||
silent_embed.set_thumbnail(url=user.display_avatar.url)
|
silent_embed.set_thumbnail(url=user.display_avatar.url)
|
||||||
|
|
||||||
# Force ephemeral response regardless of command type
|
# Send ephemeral response - force it to be ephemeral
|
||||||
if is_slash_command:
|
try:
|
||||||
if hasattr(ctx, 'followup') and ctx.followup:
|
if is_slash_command:
|
||||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
if hasattr(ctx, 'followup') and ctx.followup:
|
||||||
elif hasattr(ctx, 'response') and not ctx.response.is_done():
|
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||||
await ctx.response.send_message(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:
|
||||||
|
# If somehow we get here, try a fallback
|
||||||
|
await ctx.send(embed=silent_embed, delete_after=30)
|
||||||
else:
|
else:
|
||||||
# Fallback for slash commands without proper response
|
# For prefix commands, send and delete quickly
|
||||||
await ctx.send(embed=silent_embed, ephemeral=True)
|
msg = await ctx.send(embed=silent_embed)
|
||||||
else:
|
await asyncio.sleep(30)
|
||||||
# For prefix commands, send ephemeral-like message (delete after short time)
|
try:
|
||||||
msg = await ctx.send(embed=silent_embed)
|
await msg.delete()
|
||||||
# Auto-delete after 30 seconds for prefix commands
|
except:
|
||||||
await asyncio.sleep(30)
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error sending silent mute response: {e}")
|
||||||
|
# Last resort fallback
|
||||||
try:
|
try:
|
||||||
await msg.delete()
|
await ctx.send(f"🔇 {user.mention} has been muted silently for {duration}. Check DMs for details.", delete_after=10)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user