Collecting modal submissions

I have a command that replies to the user with some buttons. These buttons show the user a modal. The button clicks are detected using a component collector. How would I detect when the user submits the modal? Using another collector? I don't want to use the interaction create event as that would require me to create another file (due to my interaction handler). I don't want to do this as the inputs of the modal will change the message sent as the interaction reply. If anyone could help me out that would be amazing! Let me know if you need to me explain more or share code.
3 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
d.js docs
d.js docs4d ago
:method: ButtonInteraction#awaitModalSubmit() [email protected] Collects a single modal submit interaction that passes the filter. The Promise will reject if the time expires.
// Collect a modal submit interaction
const filter = (interaction) => interaction.customId === 'modal';
interaction.awaitModalSubmit({ filter, time: 15_000 })
.then(interaction => console.log(`${interaction.customId} was submitted!`))
.catch(console.error);
// Collect a modal submit interaction
const filter = (interaction) => interaction.customId === 'modal';
interaction.awaitModalSubmit({ filter, time: 15_000 })
.then(interaction => console.log(`${interaction.customId} was submitted!`))
.catch(console.error);
Goofert
GoofertOP4d ago
Thank you 🙏

Did you find this page helpful?