From de08f9b91df09418a91778818dd745076c94b990 Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Sat, 18 Apr 2026 08:50:09 -0700 Subject: [PATCH] Defers vote interaction to solve bug --- techsupport_bot/commands/voting.py | 10 +++------- techsupport_bot/ui/persistent_voting.py | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/techsupport_bot/commands/voting.py b/techsupport_bot/commands/voting.py index ae31fe96..3fd3ebfa 100644 --- a/techsupport_bot/commands/voting.py +++ b/techsupport_bot/commands/voting.py @@ -502,7 +502,7 @@ async def register_vote( # Check if voter is allowed to vote vote_ids_eligible = db_entry.vote_ids_eligible.split(",") if user_id not in vote_ids_eligible: - await interaction.response.send_message( + await interaction.followup.send( "You are not eligible to vote here.", ephemeral=True ) return @@ -511,9 +511,7 @@ async def register_vote( vote_ids = getattr(db_entry, vote_config["ids_field"]).split(",") if user_id in vote_ids: - await interaction.response.send_message( - vote_config["already_msg"], ephemeral=True - ) + await interaction.followup.send(vote_config["already_msg"], ephemeral=True) return # Remove user from any previous vote @@ -548,9 +546,7 @@ async def register_vote( embed = await self.build_vote_embed(db_entry.vote_id, interaction.guild) await interaction.message.edit(embed=embed, view=view) - await interaction.response.send_message( - vote_config["success_msg"], ephemeral=True - ) + await interaction.followup.send(vote_config["success_msg"], ephemeral=True) async def clear_vote( self: Self, diff --git a/techsupport_bot/ui/persistent_voting.py b/techsupport_bot/ui/persistent_voting.py index 9e58dfec..ca36f07c 100644 --- a/techsupport_bot/ui/persistent_voting.py +++ b/techsupport_bot/ui/persistent_voting.py @@ -29,6 +29,7 @@ async def yes_button( interaction (discord.Interaction): The interaction created when the button was pressed button (discord.ui.Button): The button object itself """ + await interaction.response.defer(ephemeral=True) cog = interaction.client.get_cog("Voting") await cog.register_vote(interaction, self, "yes") @@ -48,6 +49,7 @@ async def no_button( interaction (discord.Interaction): The interaction created when the button was pressed button (discord.ui.Button): The button object itself """ + await interaction.response.defer(ephemeral=True) cog = interaction.client.get_cog("Voting") await cog.register_vote(interaction, self, "no") @@ -67,6 +69,7 @@ async def abstain_button( interaction (discord.Interaction): The interaction created when the button was pressed button (discord.ui.Button): The button object itself """ + await interaction.response.defer(ephemeral=True) cog = interaction.client.get_cog("Voting") await cog.register_vote(interaction, self, "abstain") @@ -86,5 +89,6 @@ async def clear_button( interaction (discord.Interaction): The interaction created when the button was pressed button (discord.ui.Button): The button object itself """ + await interaction.response.defer(ephemeral=True) cog = interaction.client.get_cog("Voting") await cog.clear_vote(interaction, self)