Код: Выделить всё
@tree.command(name='test')
async def testCommand(interaction: discord.Interaction):
if await confirmationPrompt(interaction, 'run this test command'):
# Do stuff
Я хотел бы сделать параметры в эту подсказку подтверждения с помощью кнопок, поэтому я написал это:
Код: Выделить всё
async def confirmationPrompt(interaction: discord.Interaction, warning: str):
class ConfirmationButtons(discord.ui.View):
@discord.ui.button(label = '✅', style = discord.ButtonStyle.blurple)
async def returnTrue(self, interaction: discord.Interaction, button: discord.ui.Button):
return()
@discord.ui.button(label = '❌', style = discord.ButtonStyle.blurple)
async def returnFalse(self, interaction: discord.Interaction, button: discord.ui.Button):
return()
await interaction.response.send_message(
embed = discord.Embed(title = 'Are you sure you want to ' + warning),
view = ConfirmationButtons()
)
Подробнее здесь: https://stackoverflow.com/questions/796 ... discord-py