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)
|
# 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 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:
|
if is_slash_command and not silent:
|
||||||
await ctx.defer()
|
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
|
# For slash commands, use response.send_message directly for ephemeral
|
||||||
if hasattr(ctx, 'response') and not ctx.response.is_done():
|
if hasattr(ctx, 'response') and not ctx.response.is_done():
|
||||||
await ctx.response.send_message(embed=silent_embed, ephemeral=True)
|
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:
|
elif hasattr(ctx, 'followup') and ctx.followup:
|
||||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||||
|
logger.info(f"Silent warning sent via ctx.followup.send (ephemeral)")
|
||||||
else:
|
else:
|
||||||
# If somehow we get here, try a fallback
|
# This shouldn't happen for slash commands but log it
|
||||||
await ctx.send(embed=silent_embed, delete_after=30)
|
logger.error(f"Silent warning failed: No valid response method available for slash command")
|
||||||
|
raise Exception("No valid ephemeral response method available")
|
||||||
else:
|
else:
|
||||||
# For prefix commands, send and delete quickly
|
# For prefix commands, we can't do true ephemeral, so log error instead
|
||||||
msg = await ctx.send(embed=silent_embed)
|
logger.error(f"Silent warning attempted with prefix command - not supported")
|
||||||
await asyncio.sleep(30)
|
raise Exception("Silent mode only works with slash commands")
|
||||||
try:
|
|
||||||
await msg.delete()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error sending silent warning response: {e}")
|
logger.error(f"Error sending silent warning response: {e}")
|
||||||
# Send error to mod log instead of fallback message
|
# 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,
|
"Original Reason": reason,
|
||||||
"Warning ID": str(warning_id) if warning_id else "N/A",
|
"Warning ID": str(warning_id) if warning_id else "N/A",
|
||||||
"Error Details": str(e),
|
"Error Details": str(e),
|
||||||
|
"Command Type": "Slash" if is_slash_command else "Prefix",
|
||||||
"Fallback": "User received DM notification normally"
|
"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
|
# For slash commands, use response.send_message directly for ephemeral
|
||||||
if hasattr(ctx, 'response') and not ctx.response.is_done():
|
if hasattr(ctx, 'response') and not ctx.response.is_done():
|
||||||
await ctx.response.send_message(embed=silent_embed, ephemeral=True)
|
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:
|
elif hasattr(ctx, 'followup') and ctx.followup:
|
||||||
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
await ctx.followup.send(embed=silent_embed, ephemeral=True)
|
||||||
|
logger.info(f"Silent mute sent via ctx.followup.send (ephemeral)")
|
||||||
else:
|
else:
|
||||||
# If somehow we get here, try a fallback
|
# This shouldn't happen for slash commands but log it
|
||||||
await ctx.send(embed=silent_embed, delete_after=30)
|
logger.error(f"Silent mute failed: No valid response method available for slash command")
|
||||||
|
raise Exception("No valid ephemeral response method available")
|
||||||
else:
|
else:
|
||||||
# For prefix commands, send and delete quickly
|
# For prefix commands, we can't do true ephemeral, so log error instead
|
||||||
msg = await ctx.send(embed=silent_embed)
|
logger.error(f"Silent mute attempted with prefix command - not supported")
|
||||||
await asyncio.sleep(30)
|
raise Exception("Silent mode only works with slash commands")
|
||||||
try:
|
|
||||||
await msg.delete()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error sending silent mute response: {e}")
|
logger.error(f"Error sending silent mute response: {e}")
|
||||||
# Send error to mod log instead of fallback message
|
# 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",
|
"Mute ID": str(mute_id) if mute_id else "N/A",
|
||||||
"Duration": duration,
|
"Duration": duration,
|
||||||
"Error Details": str(e),
|
"Error Details": str(e),
|
||||||
|
"Command Type": "Slash" if is_slash_command else "Prefix",
|
||||||
"Fallback": "User received DM notification normally"
|
"Fallback": "User received DM notification normally"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user