Skip to content

Commit

Permalink
Remove defer
Browse files Browse the repository at this point in the history
  • Loading branch information
TLNBS2405 committed Mar 14, 2024
1 parent b808aba commit f95dcde
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/heihachi/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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)

0 comments on commit f95dcde

Please sign in to comment.