diff --git a/bot.py b/bot.py index 58e827d..b011cf8 100644 --- a/bot.py +++ b/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! """ - # 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,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_thumbnail(url=user.display_avatar.url) - # Force ephemeral response regardless of command type - 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) + # 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: + # If somehow we get here, try a fallback + await ctx.send(embed=silent_embed, delete_after=30) else: - # Fallback for slash commands without proper response - await ctx.send(embed=silent_embed, ephemeral=True) - else: - # For prefix commands, send ephemeral-like message (delete after short time) - msg = await ctx.send(embed=silent_embed) - # Auto-delete after 30 seconds for prefix commands - await asyncio.sleep(30) + # For prefix commands, send and delete quickly + msg = await ctx.send(embed=silent_embed) + 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 msg.delete() + await ctx.send(f"⚠️ {user.mention} has been warned silently. Check DMs for details.", delete_after=10) except: 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! """ - # 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,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_thumbnail(url=user.display_avatar.url) - # Force ephemeral response regardless of command type - 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) + # 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: + # If somehow we get here, try a fallback + await ctx.send(embed=silent_embed, delete_after=30) else: - # Fallback for slash commands without proper response - await ctx.send(embed=silent_embed, ephemeral=True) - else: - # For prefix commands, send ephemeral-like message (delete after short time) - msg = await ctx.send(embed=silent_embed) - # Auto-delete after 30 seconds for prefix commands - await asyncio.sleep(30) + # For prefix commands, send and delete quickly + msg = await ctx.send(embed=silent_embed) + 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 msg.delete() + await ctx.send(f"🔇 {user.mention} has been muted silently for {duration}. Check DMs for details.", delete_after=10) except: pass