From a7d187a6459c8e674553ee16cf387618e79a42ea Mon Sep 17 00:00:00 2001 From: Anorak_1 Date: Fri, 4 Aug 2023 15:40:40 +0200 Subject: [PATCH] Changed ApplicationButtonsView to disable buttons only when acc/dec modal is Submitted --- bot.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index e060b14..ba80a9e 100644 --- a/bot.py +++ b/bot.py @@ -92,8 +92,6 @@ class ApplicationButtonsView(discord.ui.View): custom_id=f"persistent:accept", ) async def accept(self, button: discord.ui.Button, interaction: discord.Interaction): - self.disable_all_items() - print(interaction.message.id) msg_id = str(interaction.message.id) con = sqlite3.connect("applications.db") cur = con.cursor() @@ -104,7 +102,6 @@ class ApplicationButtonsView(discord.ui.View): modal.set_action("acc") modal.add_item(discord.ui.InputText(label=f"Reason: ")) await interaction.response.send_modal(modal) - await interaction.followup.edit_message(message_id = interaction.message.id, view=self) @discord.ui.button( label="Decline", @@ -112,8 +109,6 @@ class ApplicationButtonsView(discord.ui.View): custom_id=f"persistent:decline", ) async def decline(self, button: discord.ui.Button, interaction: discord.Interaction): - self.disable_all_items() - print(interaction.message.id) msg_id = str(interaction.message.id) con = sqlite3.connect("applications.db") cur = con.cursor() @@ -124,7 +119,6 @@ class ApplicationButtonsView(discord.ui.View): modal.set_action("dec") modal.add_item(discord.ui.InputText(label=f"Reason: ")) await interaction.response.send_modal(modal) - await interaction.followup.edit_message(message_id = interaction.message.id, view=self) class ApplicationModal(discord.ui.Modal): def set_action(self, action): @@ -150,6 +144,9 @@ class ApplicationModal(discord.ui.Modal): embed.add_field(name=f'Reason:', value=reason, inline=False) embed.colour = discord.Colour.green() await interaction.followup.edit_message(message_id = interaction.message.id, embeds=[emb, embed]) + view = discord.ui.View.from_message(interaction.message) + view.disable_all_items() + await interaction.followup.edit_message(message_id = interaction.message.id, view = view) if self.action == "dec": user = await bot.get_user(user_id).create_dm() await user.send(f"You have been declined access to the CreatTopia Minecraft server.") @@ -161,6 +158,9 @@ class ApplicationModal(discord.ui.Modal): embed.add_field(name=f'Reason:', value=reason, inline=False) embed.colour = discord.Colour.red() await interaction.followup.edit_message(message_id = interaction.message.id, embeds=[emb, embed]) + view = discord.ui.View.from_message(interaction.message) + view.disable_all_items() + await interaction.followup.edit_message(message_id = interaction.message.id, view = view) @bot.slash_command(description = "Command used to set up the application prompt")