I’m working on a Discord bot using discord.py where the bot sends several messages with a select menu. After making 8 selections, the bot displays a ‘Continue’ button. When the button is clicked, the expected message update fails and shows ‘Interaction failed’.
Here’s what should happen:
- The bot sends an initial message with a select menu.
- The user makes 8 choices, updating the message each time.
- Once the 8 selections are done, a ‘Continue’ button appears.
- Clicking the button should update the message, but it doesn’t.
I’ve tried changing the order of message sending and editing, as well as using different interaction objects, but nothing seems to work. Below is a simplified version of my code:
async def start_quiz(interaction):
await interaction.response.send_message(embed=initial_embed, view=StartButton())
class StartButton(discord.ui.View):
@discord.ui.button(label='Start', style=discord.ButtonStyle.blurple)
async def start_callback(self, interaction, button):
await ask_question(interaction, 1)
async def ask_question(interaction, question_num):
if question_num <= 8:
await interaction.response.edit_message(embed=question_embed, view=QuestionSelect())
else:
await show_result(interaction)
class QuestionSelect(discord.ui.View):
@discord.ui.select()
async def select_callback(self, interaction, select):
# Increment question count for simplicity
await ask_question(interaction, int(interaction.message.embeds[0].footer.text) + 1)
async def show_result(interaction):
await interaction.response.edit_message(embed=result_embed, view=ContinueButton())
class ContinueButton(discord.ui.View):
@discord.ui.button(label='Continue', style=discord.ButtonStyle.blurple)
async def continue_callback(self, interaction, button):
await interaction.response.edit_message(embed=final_embed, view=None)
Any advice on how to fix this issue?