From dd52914e1890504d16f802d02b4b8cb476d45f4b Mon Sep 17 00:00:00 2001 From: SimolZimol <70102430+SimolZimol@users.noreply.github.com> Date: Wed, 20 Aug 2025 18:16:46 +0200 Subject: [PATCH] modified: bot.py --- bot.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 8716c17..410401a 100644 --- a/bot.py +++ b/bot.py @@ -2927,6 +2927,9 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess - reason: Reason for the warning - message_id: Optional message ID to reference """ + # Defer the response immediately to prevent timeout + await ctx.defer() + try: # message_data will be populated if message_id is provided message_data = None @@ -2937,7 +2940,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess try: message_id_int = int(message_id) except ValueError: - await ctx.send(f"❌ Invalid message ID: {message_id}") + await ctx.followup.send(f"❌ Invalid message ID: {message_id}") return # Try to get message data from current channel first message_data = await get_message_data(ctx.channel, message_id_int) @@ -2962,7 +2965,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.", color=0xff0000 ) - await ctx.send(embed=embed, ephemeral=True) + await ctx.followup.send(embed=embed, ephemeral=True) return # Cannot warn yourself @@ -2972,7 +2975,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess description="You cannot warn yourself!", color=0xff0000 ) - await ctx.send(embed=embed, ephemeral=True) + await ctx.followup.send(embed=embed, ephemeral=True) return # Check if target has higher permissions @@ -2984,7 +2987,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.", color=0xff0000 ) - await ctx.send(embed=embed, ephemeral=True) + await ctx.followup.send(embed=embed, ephemeral=True) return # Increase warn count @@ -3089,7 +3092,7 @@ async def warn(ctx, user: discord.User, reason: str = "No reason provided", mess inline=False ) - await ctx.send(embed=embed) + await ctx.followup.send(embed=embed) # Log the warning action log_additional_info = { @@ -3146,7 +3149,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.", color=0xff0000 ) - await ctx.send(embed=embed) + await ctx.followup.send(embed=embed) @client.hybrid_command() async def mywarns(ctx):