Getting message context after modal submission best practice

I have a message context action that gives the user a modal. When the modal is submitted, what is the best practice for getting/saving the message context that opened the modal in the first place? ChatGPT is suggesting to pass the messageID in the customID field and parsing it out, which I guess would work, but what is the best way?
No description
3 Replies
d.js toolkit
d.js toolkit2mo 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 docs2mo ago
:method: ContextMenuCommandInteraction#awaitModalSubmit() @14.16.3 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);
Kiwi
KiwiOP2mo ago
Ooooh I'll give that a shot, thanks!
Want results from more Discord servers?
Add your server