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
d.js toolkit
d.js toolkit4d ago
- 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 OP
treble/luna
treble/luna4d ago
then you are better off using the interactionCreate event awaitModalSubmit collects a single modal interaction
Goofert
GoofertOP4d ago
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?
treble/luna
treble/luna4d ago
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
d.js docs
d.js docs4d ago
:method: ModalSubmitInteraction#update() [email protected] Updates the original message of the component on which the interaction was received on.
// Remove the components from the message
interaction.update({
content: "A component interaction was received",
components: []
})
.then(console.log)
.catch(console.error);
// Remove the components from the message
interaction.update({
content: "A component interaction was received",
components: []
})
.then(console.log)
.catch(console.error);
Goofert
GoofertOP4d ago
How? Do I need to export the interaction variable so I can edit it and reply to it in the other file?
treble/luna
treble/luna4d ago
no .
Goofert
GoofertOP4d ago
I'm updating an embed based off of the modal submission though
treble/luna
treble/luna4d ago
is the embed on the message the component interaction happened on?
Goofert
GoofertOP4d ago
Yes, but it's not defined in the interactionCreate file
treble/luna
treble/luna4d ago
then use this
Goofert
GoofertOP4d ago
Wdym, the interaction or the embed isn't defined in the new file made for the event. Can you please explain more?
treble/luna
treble/luna4d ago
you call .update on the modal interaction it will update the message the interaction originated from
Goofert
GoofertOP4d ago
Ok, I understand now. Thanks so much For some reason I am now getting the Unknown interaction error whenever interaction.update is called.
d.js docs
d.js docs4d ago
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 responses
Goofert
GoofertOP4d ago
But none of that is the case
treble/luna
treble/luna4d ago
then you wouldnt get that error what happens in discord?
Goofert
GoofertOP4d ago
Thank you so much for you help.

Did you find this page helpful?