Collecting multiple modal submissions
I have a command that replies to the user with some buttons. These buttons show the user a modal. I am using the awaitModalSubmit() function to detect the modal submission. However, when the user goes to submit the other modal using the other button the code doesn't fire anymore.
If anyone could help me out that would be amazing! Let me know if you need to me explain more or share code.
18 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPthen you are better off using the interactionCreate event
awaitModalSubmit collects a single modal interaction
I was trying to stay away from that as using the interactionCreate event would need me to create a new file (due to my interaction handler). I don't want to do this as the modal input edits the original interaction reply. Do you have any other way of doing it?
you can still edit the original interaction reply from the modalsumbit (assuming its the message the modal was shown on)
otherwise you would need to call awaitModalSubmit every time
and have separate custom ids
:method: ModalSubmitInteraction#update()
[email protected]
Updates the original message of the component on which the interaction was received on.
How? Do I need to export the interaction variable so I can edit it and reply to it in the other file?
no
.
I'm updating an embed based off of the modal submission though
is the embed on the message the component interaction happened on?
Yes, but it's not defined in the interactionCreate file
then use this
Wdym, the interaction or the embed isn't defined in the new file made for the event. Can you please explain more?
you call .update on the modal interaction
it will update the message the interaction originated from
Ok, I understand now. Thanks so much
For some reason I am now getting the Unknown interaction error whenever interaction.update is called.
Common causes of
DiscordAPIError[10062]: Unknown interaction
:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responsesBut none of that is the case
then you wouldnt get that error
what happens in discord?
Thank you so much for you help.