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