From f95dcde835a2bf205e4f1f2787ca456a106a6253 Mon Sep 17 00:00:00 2001 From: lnguy Date: Thu, 14 Mar 2024 12:02:27 +0100 Subject: [PATCH] Remove defer --- src/heihachi/bot.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/heihachi/bot.py b/src/heihachi/bot.py index ecb5196..303e55a 100644 --- a/src/heihachi/bot.py +++ b/src/heihachi/bot.py @@ -56,16 +56,12 @@ async def on_ready(self) -> None: def _character_command_factory(self, name: str) -> Callable[[Interaction, str], Coroutine[Any, Any, None]]: async def command(interaction: discord.Interaction, move: str) -> None: - await interaction.response.defer() if not (self._is_user_blacklisted(str(interaction.user.id)) or self._is_author_newly_created(interaction)): logger.info( f"Received character command from {interaction.user.name} in {interaction.guild}: /fd {name} {move}" ) embed = get_frame_data_embed(self.framedb, self.frame_service, name, move) - - - await asyncio.sleep(0) - await interaction.followup.send(embed=embed, ephemeral=False) + await interaction.response.send_message(embed=embed, ephemeral=False) return command @@ -123,22 +119,17 @@ def _add_bot_commands(self) -> None: @self.tree.command(name="fd", description="Frame data from a character move") @discord.app_commands.autocomplete(character=self._character_name_autocomplete) async def _frame_data_cmd(interaction: discord.Interaction, character: str, move: str) -> None: - await interaction.response.defer() logger.info(f"Received command from {interaction.user.name} in {interaction.guild}: /fd {character} {move}") character_name_query = character move_query = move if not (self._is_user_blacklisted(str(interaction.user.id)) or self._is_author_newly_created(interaction)): embed = get_frame_data_embed(self.framedb, self.frame_service, character_name_query, move_query) - - - await asyncio.sleep(0) - await interaction.followup.send(embed=embed, ephemeral=False) + await interaction.response.send_message(embed=embed, ephemeral=False) if self.config.feedback_channel_id and self.config.action_channel_id: @self.tree.command(name="feedback", description="Send feedback to the authors in case of incorrect data") async def _feedback_cmd(interaction: discord.Interaction, message: str) -> None: - await interaction.response.defer() logger.info(f"Received command from {interaction.user.name} in {interaction.guild}: /feedback {message}") if not (self._is_user_blacklisted(str(interaction.user.id)) or self._is_author_newly_created(interaction)): # TODO: possible way to refactor these checks using discord.py library? @@ -166,18 +157,15 @@ async def _feedback_cmd(interaction: discord.Interaction, message: str) -> None: result = embed.get_error_embed(f"Feedback couldn't be sent, caused by: {traceback.format_exc()}") - await asyncio.sleep(0) - await interaction.followup.send(embed=result, ephemeral=False) + await interaction.response.send_message(embed=result, ephemeral=False) else: logger.warning("Feedback or Action channel ID is not set. Disabling feedback command.") @self.tree.command(name="help", description="Show help") async def _help_command(interaction: discord.Interaction) -> None: - await interaction.response.defer() logger.info(f"Received command from {interaction.user.name} in {interaction.guild}: /help") if not (self._is_user_blacklisted(str(interaction.user.id)) or self._is_author_newly_created(interaction)): help_embed = embed.get_help_embed(self.frame_service) - await asyncio.sleep(0) - await interaction.followup.send(embed=help_embed, ephemeral=False) + await interaction.response.send_message(embed=help_embed, ephemeral=False)