Changed ApplicationButtonsView

to disable buttons only when acc/dec modal is Submitted
main
Anorak_1 2023-08-04 15:40:40 +02:00
parent 88dc6f6294
commit a7d187a645
1 changed files with 6 additions and 6 deletions

12
bot.py
View File

@ -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")