#๐Ÿ”’ discord.py Modals - "Something went wrong, try again."

13 messages ยท Page 1 of 1 (latest)

ionic sage
#

The code:

@bot.command()
async def team_setup(message):
    view = View()
    setup_btn = Button(label="Setup", style=discord.ButtonStyle.green, emoji="๐Ÿ› ๏ธ")
    view.add_item(setup_btn)

    setup_modal = Modal(title="Team Setup")
    setup_modal.add_item(TextInput(label="Team Name", placeholder="Example: Luigi Destroyers FC", max_length=20))

    async def button_callback(interaction):
        await interaction.response.send_modal(setup_modal)

    async def on_submit(interaction: discord.Interaction):
        await message.channel.send(setup_modal.children[0].value)

    setup_modal.on_submit = on_submit
    setup_btn.callback = button_callback

    await message.channel.send("Setup your team to get started", view=view)

So you run the team_setup command, and then it responds with a button, you click it, and then a modal pops up. Once you submit the modal, it says "Something went wrong, try again."

await message.channel.send(setup_modal.children[0].value)

It does post what I entered in the modal after submitting. However, it doesn't exit the modal and instead shows the error.

torpid fieldBOT
#

@ionic sage

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

ionic sage
#

Please ping me if you need anything

vital surge
vital surge
#

you didn't respond to the interaction here so it thinks something went wrong

ionic sage
#

ooh okay

vital surge
#

interaction.response.* methods all respond to an interaction

ionic sage
#

k thanks

#

!close

torpid fieldBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.