Collectors crashing bot

await buttonInteraction.showModal(modal);
// Collect a modal submit interaction
const filter = (inter: ModalSubmitInteraction): boolean => inter.message!.id === buttonInteraction.message.id;
let modalSubmit: ModalSubmitInteraction;
try {
modalSubmit = await buttonInteraction.awaitModalSubmit({ filter, time: 30_000 });
}
catch (error) {
await buttonInteraction.followUp({ content :'You did not reply in time!', ephemeral : true });
return;
}
await buttonInteraction.showModal(modal);
// Collect a modal submit interaction
const filter = (inter: ModalSubmitInteraction): boolean => inter.message!.id === buttonInteraction.message.id;
let modalSubmit: ModalSubmitInteraction;
try {
modalSubmit = await buttonInteraction.awaitModalSubmit({ filter, time: 30_000 });
}
catch (error) {
await buttonInteraction.followUp({ content :'You did not reply in time!', ephemeral : true });
return;
}
In this case when you: 1. click on button (modal shows up) 2. cancel modal 3. click on button again (modal shows up) 4. fill modal and submit Handled error:
DiscordAPIError[10062]: Unknown interaction
0|index | at handleErrors (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:687:13)
0|index | at processTicksAndRejections (node:internal/process/task_queues:96:5)
0|index | at async BurstHandler.runRequest (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:786:23)
0|index | at async _REST.request (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
DiscordAPIError[10062]: Unknown interaction
0|index | at handleErrors (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:687:13)
0|index | at processTicksAndRejections (node:internal/process/task_queues:96:5)
0|index | at async BurstHandler.runRequest (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:786:23)
0|index | at async _REST.request (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
unhandled error:
0|index | /Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:687
0|index | throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
0|index | ^
0|index | DiscordAPIError[10008]: Unknown Message
0|index | /Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:687
0|index | throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
0|index | ^
0|index | DiscordAPIError[10008]: Unknown Message
6 Replies
d.js toolkit
d.js toolkit12mo 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 staff
War
WarOP12mo ago
The filter for the collector is set to the message id, so when someone uses it twice, both collectors fire. Is there any solution possible?
monbrey
monbrey12mo ago
Filter on the modals custom id, and make it unique each time the modal opens
War
WarOP12mo ago
Wow. gotcha, thanks.
monbrey
monbrey12mo ago
Easiest way to do that is just to include the button interaction id in the modal custom id
War
WarOP12mo ago
I see, wow, thank you, trying now. Works, thank you.
Want results from more Discord servers?
Add your server