error modal

DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (D:\MartozAifoo\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (D:\MartozAifoo\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (D:\MartozAifoo\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async ButtonInteraction.showModal (D:\MartozAifoo\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:257:5)
at async InteractionCollector.<anonymous> (D:\MartozAifoo\core\commands\VerifySystem.js:82:17) {
requestBody: { files: undefined, json: { type: 9, data: [Object] } },
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1317790941397913632/aW50ZXJhY3Rpb246MTMxNzc5MDk0MTM5NzkxMzYzMjpNTk9oaVJqUDVidXZlcGgyTk5DSmw3dWkyNWJWR2dNZ205bTdMbjk2aEpUdktJV3c2ZGhsWEhMRjE4aTBQb1lQckhlUVhtb3FzRFZ3RUVRUHhWdWFqSU9qVTR2NVlHa245UUdrcXFheHg4Z09ick1aVkZFSlMwT1FuZzk2TzFYWg/callback'
}
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (D:\MartozAifoo\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (D:\MartozAifoo\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (D:\MartozAifoo\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async ButtonInteraction.showModal (D:\MartozAifoo\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:257:5)
at async InteractionCollector.<anonymous> (D:\MartozAifoo\core\commands\VerifySystem.js:82:17) {
requestBody: { files: undefined, json: { type: 9, data: [Object] } },
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1317790941397913632/aW50ZXJhY3Rpb246MTMxNzc5MDk0MTM5NzkxMzYzMjpNTk9oaVJqUDVidXZlcGgyTk5DSmw3dWkyNWJWR2dNZ205bTdMbjk2aEpUdktJV3c2ZGhsWEhMRjE4aTBQb1lQckhlUVhtb3FzRFZ3RUVRUHhWdWFqSU9qVTR2NVlHa245UUdrcXFheHg4Z09ick1aVkZFSlMwT1FuZzk2TzFYWg/callback'
}
const collector = dmChannel.createMessageComponentCollector({ filter, time: 60000 });

collector.on('collect', async (interaction) => {
try {
if (interaction.replied || interaction.deferred) {
console.log('Взаимодействие уже завершено или отложено');
return;
}

if (interaction.isModalSubmit()) {
console.log('Модальное окно уже было показано');
return;
}

const modal = new ModalBuilder()
.setCustomId('captcha_modal')
.setTitle('Введите капчу')
.addComponents(
new ActionRowBuilder().addComponents(
new TextInputBuilder()
.setCustomId('captcha_input')
.setLabel('Введите текст с картинки')
.setStyle(TextInputStyle.Short)
.setRequired(true)
)
);
await interaction.showModal(modal);
} catch(error) {
console.log(error)
}
})



collector.on('end', async (collected) => {
if (collected.size === 0) {
await user.send('⏳ Время вышло. Попробуйте снова использовать команду /verify.');
}
});
} catch (error) {
console.error('Ошибка в процессе верификации:', error);
await user.send('Произошла ошибка. Попробуйте снова позже.');
}
}
const collector = dmChannel.createMessageComponentCollector({ filter, time: 60000 });

collector.on('collect', async (interaction) => {
try {
if (interaction.replied || interaction.deferred) {
console.log('Взаимодействие уже завершено или отложено');
return;
}

if (interaction.isModalSubmit()) {
console.log('Модальное окно уже было показано');
return;
}

const modal = new ModalBuilder()
.setCustomId('captcha_modal')
.setTitle('Введите капчу')
.addComponents(
new ActionRowBuilder().addComponents(
new TextInputBuilder()
.setCustomId('captcha_input')
.setLabel('Введите текст с картинки')
.setStyle(TextInputStyle.Short)
.setRequired(true)
)
);
await interaction.showModal(modal);
} catch(error) {
console.log(error)
}
})



collector.on('end', async (collected) => {
if (collected.size === 0) {
await user.send('⏳ Время вышло. Попробуйте снова использовать команду /verify.');
}
});
} catch (error) {
console.error('Ошибка в процессе верификации:', error);
await user.send('Произошла ошибка. Попробуйте снова позже.');
}
}
10 Replies
d.js toolkit
d.js toolkit3d 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!
Tok | supremecheats.xyz
Above your collecter try
interaction.deferReply();
interaction.deferReply();
Martoz
MartozOP3d ago
No description
Martoz
MartozOP3d ago
infinity
DiscordAPIError[40060]: Interaction has already been acknowledged.
DiscordAPIError[40060]: Interaction has already been acknowledged.
it comes out when I check that if the user did not enter the captcha correctly, he sent a new one, yes, he sends everything works, but when I click on the button on the new captcha, an error pops out, and so everything works. It's just that this mistake is bothering me.
d.js docs
d.js docs3d ago
If you are waiting for button or select menu input from a specific message, don't create the collector on the channel. - Channel collectors return component interactions for any component within that channel.
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
treble/luna
treble/luna3d ago
Also modals arent measage components You also cannot show a modal after another one ah wait, you return if it is one, but it will never be one You cannot defer and show a modal
Martoz
MartozOP3d ago
?
client.on('interactionCreate', async (interaction) => {
try {
if (interaction.isChatInputCommand()) {
await handleCommandInteraction(interaction);
} else if (interaction.isButton()) {
if (interaction.replied || interaction.deferred) {
console.log('Button interaction already acknowledged.');
return;
}
buttonHandlers.handleButtonInteraction(interaction);
} else if (interaction.isModalSubmit()) {
if (interaction.replied || interaction.deferred) {
console.log('Modal interaction already acknowledged.');
return;
}
const { handleModalSubmit } = require('./core/commands/VerifySystem');
await handleModalSubmit(interaction);
}
} catch (error) {
console.error('Error during interaction:', error);
}
});
client.on('interactionCreate', async (interaction) => {
try {
if (interaction.isChatInputCommand()) {
await handleCommandInteraction(interaction);
} else if (interaction.isButton()) {
if (interaction.replied || interaction.deferred) {
console.log('Button interaction already acknowledged.');
return;
}
buttonHandlers.handleButtonInteraction(interaction);
} else if (interaction.isModalSubmit()) {
if (interaction.replied || interaction.deferred) {
console.log('Modal interaction already acknowledged.');
return;
}
const { handleModalSubmit } = require('./core/commands/VerifySystem');
await handleModalSubmit(interaction);
}
} catch (error) {
console.error('Error during interaction:', error);
}
});
treble/luna
treble/luna3d ago
Your collector wont prevent the interactionCreate event from firing So your button might still be handled there But still this
Martoz
MartozOP3d ago
I'll try it right now
DiscordAPIError[40060]: Interaction has already been acknowledged
DiscordAPIError[40060]: Interaction has already been acknowledged
const collector = user.dmChannel.createMessageComponentCollector({ filter, time: 60000 });
treble/luna
treble/luna3d ago
Still this
Want results from more Discord servers?
Add your server