From 62b7def76b783bf65074819806f422a523ab43d8 Mon Sep 17 00:00:00 2001 From: SylteA Date: Mon, 17 Jul 2023 17:04:27 +0200 Subject: [PATCH] Defer the response and send replies as followups in case we take too long to respond. --- bot/extensions/challenges/commands.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot/extensions/challenges/commands.py b/bot/extensions/challenges/commands.py index d8b16e5b..af170bd7 100644 --- a/bot/extensions/challenges/commands.py +++ b/bot/extensions/challenges/commands.py @@ -213,6 +213,8 @@ async def submit(self, interaction: core.InteractionType, attachment: discord.At "File extension must be between 1 and 4 characters.", ephemeral=True ) + await interaction.response.defer(ephemeral=True, thinking=True) + code = (await attachment.read()).decode("u8") log.info(len(code) == attachment.size) @@ -222,7 +224,7 @@ async def submit(self, interaction: core.InteractionType, attachment: discord.At max_user_length = 4096 - len(filetype) - 7 msg = f"Your submission can't be __more than {max_user_length} characters__." - return await interaction.response.send_message(msg, ephemeral=True) + return await interaction.followup.send(msg, ephemeral=True) await interaction.user.add_roles(self.submitted_role) @@ -233,4 +235,4 @@ async def submit(self, interaction: core.InteractionType, attachment: discord.At embed.set_author(name="Your submission", icon_url=interaction.user.display_avatar.url) embed.set_footer(text=f"{len(code)} chars • Language: {filetype}") - return await interaction.response.send_message(embed=embed, ephemeral=True) + return await interaction.followup.send(embed=embed, ephemeral=True)