#Modal not showing up

1 messages · Page 1 of 1 (latest)

viscid houndBOT
#

Hey @mossy sluice!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
mossy sluice
#

I have an embed with a button, which when clicked should pop up a modal. However when I do it it doesn't show the modal. And I get a nextcord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged. error. And I can't do a followup since it's a modal - I am also not deferring it either.

However, when I restart my bot and click the button again it works perfectly fine. How do I fix this so I don't have to restart the bot every time after sending an embed?

@commands.Cog.listener()
    async def on_interaction(self, interaction: nextcord.Interaction):
        if not interaction.type == nextcord.InteractionType.component:
            return

        if interaction.data["component_type"] == 2:
            custom_id = interaction.data["custom_id"]
            if custom_id.startswith("use_button"):
                try:
                    await interaction.response.send_modal(QuantityModal())
                except:
                    await interaction.followup.send_modal(QuantityModal())```

```py
view = nextcord.ui.View(timeout=None)
            view.add_item(nextcord.ui.Button(label="Use some.", style=nextcord.ButtonStyle.primary, custom_id="use_button"))```