Whenever my slash command gets used for 2 times it gives an error

node:events:492
throw er; // Unhandled 'error' event
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (C:\Users\Yiğit\Desktop\Catto\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\Yiğit\Desktop\Catto\node_modules\@discordjs\rest\dist\index.js:826:23)
at async _REST.request (C:\Users\Yiğit\Desktop\Catto\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async ModalSubmitInteraction.reply (C:\Users\Yiğit\Desktop\Catto\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
at async Client.<anonymous> (C:\Users\Yiğit\Desktop\Catto\events\suggestion_modal.js:38:21)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:397:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'Your suggestion was received successfully!',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1227237570832891984/aW50ZXJhY3Rpb246MTIyNzIzNzU3MDgzMjg5MTk4NDpCOGhsWjY2ME43NXFUWEw1SFpCRkkwbjhXb2FQRUdnTlhFTnJMcmpvMHZFUzNFa3hTSDlHR2VUTmY3V0h0dEQyR2pUSVBOQU0zQ0NEZGhNc2JuckpOZVV4TVZYQkk2SjVrdXJQcnduMk10MWxKNGt4TG5Qc1ZRa2w3dkt2RG1EWQ/callback'
}

Node.js v20.10.0
node:events:492
throw er; // Unhandled 'error' event
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (C:\Users\Yiğit\Desktop\Catto\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\Yiğit\Desktop\Catto\node_modules\@discordjs\rest\dist\index.js:826:23)
at async _REST.request (C:\Users\Yiğit\Desktop\Catto\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async ModalSubmitInteraction.reply (C:\Users\Yiğit\Desktop\Catto\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
at async Client.<anonymous> (C:\Users\Yiğit\Desktop\Catto\events\suggestion_modal.js:38:21)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:397:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'Your suggestion was received successfully!',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1227237570832891984/aW50ZXJhY3Rpb246MTIyNzIzNzU3MDgzMjg5MTk4NDpCOGhsWjY2ME43NXFUWEw1SFpCRkkwbjhXb2FQRUdnTlhFTnJMcmpvMHZFUzNFa3hTSDlHR2VUTmY3V0h0dEQyR2pUSVBOQU0zQ0NEZGhNc2JuckpOZVV4TVZYQkk2SjVrdXJQcnduMk10MWxKNGt4TG5Qc1ZRa2w3dkt2RG1EWQ/callback'
}

Node.js v20.10.0
3 Replies
d.js toolkit
d.js toolkit9mo 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!
Yido
YidoOP9mo ago
i did not understand what ı should do
const { ActionRowBuilder, Events, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');

module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'suggest') {
// Create the modal
const modal = new ModalBuilder()
.setCustomId('suggestionModal')
.setTitle('Suggestion Form');

// Add components to modal

// Create the text input components
const suggestion_input = new TextInputBuilder()
.setCustomId('suggestion_input')
// The label is the prompt the user sees for this input
.setLabel("Your suggestion")
// Short means only a single line of text
.setStyle(TextInputStyle.Paragraph);

// so you need one action row per text input.
const firstActionRow = new ActionRowBuilder().addComponents(suggestion_input);

// Add inputs to the modal
modal.addComponents(firstActionRow);

// Show the modal to the user
await interaction.showModal(modal);

client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isModalSubmit()) return;
await interaction.reply({ content: 'Your suggestion was received successfully!', ephemeral: true});
// Get the data entered by the user
const suggestion_input = interaction.fields.getTextInputValue('suggestion_input');
console.log(`${interaction.user.tag} || ${suggestion_input}`, );
});
}
});
},
};
const { ActionRowBuilder, Events, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');

module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'suggest') {
// Create the modal
const modal = new ModalBuilder()
.setCustomId('suggestionModal')
.setTitle('Suggestion Form');

// Add components to modal

// Create the text input components
const suggestion_input = new TextInputBuilder()
.setCustomId('suggestion_input')
// The label is the prompt the user sees for this input
.setLabel("Your suggestion")
// Short means only a single line of text
.setStyle(TextInputStyle.Paragraph);

// so you need one action row per text input.
const firstActionRow = new ActionRowBuilder().addComponents(suggestion_input);

// Add inputs to the modal
modal.addComponents(firstActionRow);

// Show the modal to the user
await interaction.showModal(modal);

client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isModalSubmit()) return;
await interaction.reply({ content: 'Your suggestion was received successfully!', ephemeral: true});
// Get the data entered by the user
const suggestion_input = interaction.fields.getTextInputValue('suggestion_input');
console.log(`${interaction.user.tag} || ${suggestion_input}`, );
});
}
});
},
};
Want results from more Discord servers?
Add your server