modified: bot.py
This commit is contained in:
26
bot.py
26
bot.py
@@ -2927,8 +2927,18 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
- reason: Reason for the warning
|
- reason: Reason for the warning
|
||||||
- message_id: Optional message ID to reference
|
- message_id: Optional message ID to reference
|
||||||
"""
|
"""
|
||||||
# Defer the response immediately to prevent timeout
|
# Defer the response immediately to prevent timeout (only for slash commands)
|
||||||
await ctx.defer()
|
if hasattr(ctx, 'interaction') and ctx.interaction:
|
||||||
|
await ctx.defer()
|
||||||
|
|
||||||
|
# Helper function to send messages correctly based on command type
|
||||||
|
async def send_response(content=None, embed=None, ephemeral=False):
|
||||||
|
if hasattr(ctx, 'interaction') and ctx.interaction:
|
||||||
|
# Slash command - use followup
|
||||||
|
await ctx.followup.send(content=content, embed=embed, ephemeral=ephemeral)
|
||||||
|
else:
|
||||||
|
# Prefix command - use normal send
|
||||||
|
await ctx.send(content=content, embed=embed)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# message_data will be populated if message_id is provided
|
# message_data will be populated if message_id is provided
|
||||||
@@ -2940,7 +2950,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
try:
|
try:
|
||||||
message_id_int = int(message_id)
|
message_id_int = int(message_id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
await ctx.followup.send(f"❌ Invalid message ID: {message_id}")
|
await send_response(content=f"❌ Invalid message ID: {message_id}")
|
||||||
return
|
return
|
||||||
# Try to get message data from current channel first
|
# Try to get message data from current channel first
|
||||||
message_data = await get_message_data(ctx.channel, message_id_int)
|
message_data = await get_message_data(ctx.channel, message_id_int)
|
||||||
@@ -2965,7 +2975,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
description="You need moderation permissions (Level 5 or higher) to use this command.",
|
description="You need moderation permissions (Level 5 or higher) to use this command.",
|
||||||
color=0xff0000
|
color=0xff0000
|
||||||
)
|
)
|
||||||
await ctx.followup.send(embed=embed, ephemeral=True)
|
await send_response(embed=embed, ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Cannot warn yourself
|
# Cannot warn yourself
|
||||||
@@ -2975,7 +2985,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
description="You cannot warn yourself!",
|
description="You cannot warn yourself!",
|
||||||
color=0xff0000
|
color=0xff0000
|
||||||
)
|
)
|
||||||
await ctx.followup.send(embed=embed, ephemeral=True)
|
await send_response(embed=embed, ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check if target has higher permissions
|
# Check if target has higher permissions
|
||||||
@@ -2987,7 +2997,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
description="You cannot warn someone with equal or higher permissions than you.",
|
description="You cannot warn someone with equal or higher permissions than you.",
|
||||||
color=0xff0000
|
color=0xff0000
|
||||||
)
|
)
|
||||||
await ctx.followup.send(embed=embed, ephemeral=True)
|
await send_response(embed=embed, ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Increase warn count
|
# Increase warn count
|
||||||
@@ -3092,7 +3102,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
inline=False
|
inline=False
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.followup.send(embed=embed)
|
await send_response(embed=embed)
|
||||||
|
|
||||||
# Log the warning action
|
# Log the warning action
|
||||||
log_additional_info = {
|
log_additional_info = {
|
||||||
@@ -3149,7 +3159,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess
|
|||||||
description="An error occurred while processing the warning. Please try again.",
|
description="An error occurred while processing the warning. Please try again.",
|
||||||
color=0xff0000
|
color=0xff0000
|
||||||
)
|
)
|
||||||
await ctx.followup.send(embed=embed)
|
await send_response(embed=embed)
|
||||||
|
|
||||||
@client.hybrid_command()
|
@client.hybrid_command()
|
||||||
async def mywarns(ctx):
|
async def mywarns(ctx):
|
||||||
|
|||||||
Reference in New Issue
Block a user