Modal submit problem

look this is my collector, which collects message from a button
const msg = await thread.send({ content: null, embeds: [embed], components: [row] });
message.reply({
content: `created a new thread, <#${thread.id}>`
})

const collector = await msg.createMessageComponentCollector();
collector.on('collect', async (m) => {
const msg = await thread.send({ content: null, embeds: [embed], components: [row] });
message.reply({
content: `created a new thread, <#${thread.id}>`
})

const collector = await msg.createMessageComponentCollector();
collector.on('collect', async (m) => {
and this is the modal inside of the collector:
await m.showModal(modal).catch(console.error);

const modalSubmit = await m.awaitModalSubmit({
filter: async (mm) => mm.user.id === message.author.id && mm.customId == message.id,
time: 1_800_000
});
await m.showModal(modal).catch(console.error);

const modalSubmit = await m.awaitModalSubmit({
filter: async (mm) => mm.user.id === message.author.id && mm.customId == message.id,
time: 1_800_000
});
when i open this modal and click somewhere on the screen, that means to disappear it and execute the modal again, it throws this error
DiscordAPIError[10062]: Unknown interaction
at handleErrors (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:786:23)
at async _REST.request (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async ModalSubmitInteraction.reply (G:\#BotBackups\BeastCorp\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
at async InteractionCollector.<anonymous> (G:\#BotBackups\BeastCorp\src\prefix-commands\thread.js:115:23) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
DiscordAPIError[10062]: Unknown interaction
at handleErrors (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:786:23)
at async _REST.request (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async ModalSubmitInteraction.reply (G:\#BotBackups\BeastCorp\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
at async InteractionCollector.<anonymous> (G:\#BotBackups\BeastCorp\src\prefix-commands\thread.js:115:23) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
11 Replies
d.js toolkit
d.js toolkit4mo 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!
treble/luna
treble/luna4mo ago
you dont store the interaction id i'm not sure where you're pulling that message from since messages cant trigger modals
Resident Of Prey
interaction doesnt get involved here its a message which was triggered from a prefix cmd
treble/luna
treble/luna4mo ago
messages cant show modals
Resident Of Prey
it does show
treble/luna
treble/luna4mo ago
Show the full code
Resident Of Prey
module.exports = {
name: `thread`,
description: `Create a thread for tryout purposes`,
aliases: ['t'],
async execute(client, message, args) {
//...

const msg = await thread.send({ content: null, embeds: [embed], components: [row] });

const collector = await msg.createMessageComponentCollector();
collector.on('collect', async (m) => {

const modal = new ModalBuilder()
.setCustomId(message.id)
.setTitle('Choose the region of participant')

const textInput = new TextInputBuilder()
.setCustomId('region01')
.setLabel('Region Role (2 letters Capitalized)')
.setPlaceholder('AS / EU / NA')
.setStyle(TextInputStyle.Short)
.setRequired(true);

const oneRow = new ActionRowBuilder().addComponents(textInput)
modal.addComponents(oneRow)
await m.showModal(modal).catch(console.error);

try {
// const filter = (message) => message.customId === 'threadRole';
const modalSubmit = await m.awaitModalSubmit({
filter: async (mm) => mm.user.id === message.author.id && mm.customId == message.id,
time: 1_800_000
});
if (modalSubmit instanceof ModalSubmitInteraction) {
const regionRole = modalSubmit.fields.getTextInputValue('region01');
module.exports = {
name: `thread`,
description: `Create a thread for tryout purposes`,
aliases: ['t'],
async execute(client, message, args) {
//...

const msg = await thread.send({ content: null, embeds: [embed], components: [row] });

const collector = await msg.createMessageComponentCollector();
collector.on('collect', async (m) => {

const modal = new ModalBuilder()
.setCustomId(message.id)
.setTitle('Choose the region of participant')

const textInput = new TextInputBuilder()
.setCustomId('region01')
.setLabel('Region Role (2 letters Capitalized)')
.setPlaceholder('AS / EU / NA')
.setStyle(TextInputStyle.Short)
.setRequired(true);

const oneRow = new ActionRowBuilder().addComponents(textInput)
modal.addComponents(oneRow)
await m.showModal(modal).catch(console.error);

try {
// const filter = (message) => message.customId === 'threadRole';
const modalSubmit = await m.awaitModalSubmit({
filter: async (mm) => mm.user.id === message.author.id && mm.customId == message.id,
time: 1_800_000
});
if (modalSubmit instanceof ModalSubmitInteraction) {
const regionRole = modalSubmit.fields.getTextInputValue('region01');
treble/luna
treble/luna4mo ago
yep you're using an interaction so store that id Not the author id
Resident Of Prey
you mean
-filter: async (mm) => mm.user.id === message.author.id && mm.customId == message.id,

+filter: async (mm) => mm.user.id === message.user.id && mm.customId == message.id,
-filter: async (mm) => mm.user.id === message.author.id && mm.customId == message.id,

+filter: async (mm) => mm.user.id === message.user.id && mm.customId == message.id,
?
treble/luna
treble/luna4mo ago
...no do you even know what your code does
Resident Of Prey
yes i made it so what exactly are you saying i didnt get it want to know what causes disturbance with the moadal when triggered again for 2nd time after it was cancelled 1st time unclear part was what do you mean by confuse those two messages thanks