modified: bot.py
This commit is contained in:
38
bot.py
38
bot.py
@@ -4758,6 +4758,8 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
||||
"""
|
||||
# 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 silent:
|
||||
logger.info(f"Silent warn command - is_slash_command: {is_slash_command}, has interaction: {hasattr(ctx, 'interaction')}, interaction value: {getattr(ctx, 'interaction', None)}")
|
||||
if is_slash_command and not silent:
|
||||
await ctx.defer()
|
||||
|
||||
@@ -5034,19 +5036,18 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
||||
# 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)
|
||||
logger.info(f"Silent warning sent via ctx.response.send_message (ephemeral)")
|
||||
elif hasattr(ctx, 'followup') and ctx.followup:
|
||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||
logger.info(f"Silent warning sent via ctx.followup.send (ephemeral)")
|
||||
else:
|
||||
# If somehow we get here, try a fallback
|
||||
await ctx.send(embed=silent_embed, delete_after=30)
|
||||
# This shouldn't happen for slash commands but log it
|
||||
logger.error(f"Silent warning failed: No valid response method available for slash command")
|
||||
raise Exception("No valid ephemeral response method available")
|
||||
else:
|
||||
# For prefix commands, send and delete quickly
|
||||
msg = await ctx.send(embed=silent_embed)
|
||||
await asyncio.sleep(30)
|
||||
try:
|
||||
await msg.delete()
|
||||
except:
|
||||
pass
|
||||
# For prefix commands, we can't do true ephemeral, so log error instead
|
||||
logger.error(f"Silent warning attempted with prefix command - not supported")
|
||||
raise Exception("Silent mode only works with slash commands")
|
||||
except Exception as e:
|
||||
logger.error(f"Error sending silent warning response: {e}")
|
||||
# Send error to mod log instead of fallback message
|
||||
@@ -5061,6 +5062,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
||||
"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"
|
||||
}
|
||||
)
|
||||
@@ -6634,19 +6636,18 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
|
||||
# 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)
|
||||
logger.info(f"Silent mute sent via ctx.response.send_message (ephemeral)")
|
||||
elif hasattr(ctx, 'followup') and ctx.followup:
|
||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||
logger.info(f"Silent mute sent via ctx.followup.send (ephemeral)")
|
||||
else:
|
||||
# If somehow we get here, try a fallback
|
||||
await ctx.send(embed=silent_embed, delete_after=30)
|
||||
# This shouldn't happen for slash commands but log it
|
||||
logger.error(f"Silent mute failed: No valid response method available for slash command")
|
||||
raise Exception("No valid ephemeral response method available")
|
||||
else:
|
||||
# For prefix commands, send and delete quickly
|
||||
msg = await ctx.send(embed=silent_embed)
|
||||
await asyncio.sleep(30)
|
||||
try:
|
||||
await msg.delete()
|
||||
except:
|
||||
pass
|
||||
# For prefix commands, we can't do true ephemeral, so log error instead
|
||||
logger.error(f"Silent mute attempted with prefix command - not supported")
|
||||
raise Exception("Silent mode only works with slash commands")
|
||||
except Exception as e:
|
||||
logger.error(f"Error sending silent mute response: {e}")
|
||||
# Send error to mod log instead of fallback message
|
||||
@@ -6663,6 +6664,7 @@ async def mute(ctx, user: discord.User, duration: str, reason: str = "No reason
|
||||
"Mute ID": str(mute_id) if mute_id else "N/A",
|
||||
"Duration": duration,
|
||||
"Error Details": str(e),
|
||||
"Command Type": "Slash" if is_slash_command else "Prefix",
|
||||
"Fallback": "User received DM notification normally"
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user