unknown interaction

Node version: v20.19.5 Discord.js version: discord.js@14.23.2 OS: Ubuntu So, when I try to run any bot, it throws the following error:
❯ node src/index.js
Logged in as questos#5656!
node:events:497
throw er; // Unhandled 'error' event
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async BurstHandler.runRequest (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:866:23)
at async _REST.request (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:1307:22)
at async ChatInputCommandInteraction.reply (/home/renegildo/code/discord/example/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:193:22)
at async Client.<anonymous> (file:///home/renegildo/code/discord/example/src/index.js:13:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:402:10)
at process.processTicksAndRejections
❯ node src/index.js
Logged in as questos#5656!
node:events:497
throw er; // Unhandled 'error' event
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async BurstHandler.runRequest (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:866:23)
at async _REST.request (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:1307:22)
at async ChatInputCommandInteraction.reply (/home/renegildo/code/discord/example/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:193:22)
at async Client.<anonymous> (file:///home/renegildo/code/discord/example/src/index.js:13:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:402:10)
at process.processTicksAndRejections
[continues]
18 Replies
d.js toolkit
d.js toolkit2mo ago
renegildo
renegildoOP2mo ago
(node:internal/process/task_queues:92:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'Pong!',
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1430220555608391854/aW50ZXJhY3Rpb246MTQzMDIyMDU1NTYwODM5MTg1NDpSZkF2UDJ0RG51ZnhzZzkwSk14VjhRQXJPWmFqV1U4V2xhcHkza3RueVNFNWRGYmw3Y2ZYRjhwM0Z6UjQ2cUF5WDhhQzh2MjE0MUY0TjFxczFOR2dzbzNDWDlXQzVtUEZyQkZHMHoxSGlTQnRrQ2EybG0xQ1ZmMHgxQkRkMXFkeQ/callback?with_response=false'
}

Node.js v22.21.0
(node:internal/process/task_queues:92:21) {
requestBody: {
files: [],
json: {
type: 4,
data: {
content: 'Pong!',
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
}
},
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1430220555608391854/aW50ZXJhY3Rpb246MTQzMDIyMDU1NTYwODM5MTg1NDpSZkF2UDJ0RG51ZnhzZzkwSk14VjhRQXJPWmFqV1U4V2xhcHkza3RueVNFNWRGYmw3Y2ZYRjhwM0Z6UjQ2cUF5WDhhQzh2MjE0MUY0TjFxczFOR2dzbzNDWDlXQzVtUEZyQkZHMHoxSGlTQnRrQ2EybG0xQ1ZmMHgxQkRkMXFkeQ/callback?with_response=false'
}

Node.js v22.21.0
I say any bot because I had many troubles with Unknown interaction while trying to develop my actual bot, and then I tried running that simple example from the docs to troubleshoot. index.js:
import { Client, Events, GatewayIntentBits } from 'discord.js';

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.on(Events.ClientReady, readyClient => {
console.log(`Logged in as ${readyClient.user.tag}!`);
});

client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});

client.login("<my-actual-token>");
import { Client, Events, GatewayIntentBits } from 'discord.js';

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.on(Events.ClientReady, readyClient => {
console.log(`Logged in as ${readyClient.user.tag}!`);
});

client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});

client.login("<my-actual-token>");
register.js:
import { REST, Routes } from 'discord.js';

const commands = [
{
name: 'ping',
description: 'Replies with Pong!',
},
];

const rest = new REST({ version: '10' }).setToken("<my-actual-token>");

try {
console.log('Started refreshing application (/) commands.');

await rest.put(Routes.applicationCommands("<my-actual-client-id>"), { body: commands });

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
import { REST, Routes } from 'discord.js';

const commands = [
{
name: 'ping',
description: 'Replies with Pong!',
},
];

const rest = new REST({ version: '10' }).setToken("<my-actual-token>");

try {
console.log('Started refreshing application (/) commands.');

await rest.put(Routes.applicationCommands("<my-actual-client-id>"), { body: commands });

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
Even with this extremely simple setup, the exact error occurs. I’m using "type": "module" in my package.json and running the file via node src/index.js. I tried both Routes.applicationCommands() and Routes.applicationGuildCommands(<clientId>, <guildId>); the error occurs in both cases. I am running the bot from my machine (no Docker), so it can't be some slow host issue; my PC is good. In Discord the message "The application did not respond" appears. What could be the problem here? I can share more information about my machine and anything else.
d.js docs
d.js docs2mo ago
Common causes of DiscordAPIError[10062]: Unknown interaction: - Initial response took more than 3 seconds ➞ defer the response *. - Wrong interaction object inside a collector. - Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance) * Note: you cannot defer modal or autocomplete value responses
renegildo
renegildoOP2mo ago
because of the 3 seconds thing How do I check that If that could be the problem the change:
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

console.log(interaction.createdTimestamp, Date.now())

if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

console.log(interaction.createdTimestamp, Date.now())

if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
the logs:
Logged in as questos#5656!
1761062935834 1761062936035
node:events:502
throw er; // Unhandled 'error' event
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:866:23)
[...]
Logged in as questos#5656!
1761062935834 1761062936035
node:events:502
throw er; // Unhandled 'error' event
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/home/renegildo/code/discord/example/node_modules/@discordjs/rest/dist/index.js:866:23)
[...]
Inky
Inky2mo ago
Try killing the bot and then execute the command while the bot is offline
renegildo
renegildoOP2mo ago
got the same: "The application did not respond", why would this help?
Inky
Inky2mo ago
Unknown Interaction is also caused by replying twice Running multiple instances of the bot is a common culprit
if (!CR4I5) return;
Use deferReply And instead of using interaction.reply use interaction.editReply
Inky
Inky5w ago
If reply isn’t working, deferReply won’t either. Unless you are saying one of the lines from the beginning of the event callback are talking an egregious amount of time to run
if (!CR4I5) return;
My bad if I'm screwed it up, my English is not that good, but, I mean, u can use deferReply at the beginning of the command code, it works for me
renegildo
renegildoOP5w ago
yeah, it doesn't work either
Inky
Inky5w ago
Using deferReply like that prevents you from using other responses in the command like showModal
if (!CR4I5) return;
Oh, I see, thanks, and sorry for giving a bad answer
Inky
Inky5w ago
It’s fine. As long as you learned smth. Still can’t think of what else would cause it Are you running the bot on a shared hosting platform?
renegildo
renegildoOP5w ago
no, i am running it locally
if (!CR4I5) return;
U should kill every terminal u have, and as my last suggestion, why u don't try to do a commandHandler and an event handler?
renegildo
renegildoOP5w ago
this is the most minimal setup possible for isolating the problem, so adding commandHandler and stuff could add more complexity and the error could be somewhere else, that's why I am not using it by now. When I fix it, I'll use the "correct" approach oh, that worked
import { Client, GatewayIntentBits } from 'discord.js';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.on('interactionCreate', interaction => interaction.reply('reply'));
client.login("<token>");
import { Client, GatewayIntentBits } from 'discord.js';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.on('interactionCreate', interaction => interaction.reply('reply'));
client.login("<token>");
did actually worked well, i'll investigate further at least it's not a lib issue So, it looks like that kind of issue about the bot "replying" with "The application did not respond" is something that just happens sometimes, so I just added a try catch block around the command.execute(interaction); line of the interactionCreate event without any answer to the user (just a console.error printing what went wrong) like this:
const { Events } = require('discord.js');

module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;

if (!interaction.isRepliable()) {
console.log('Interaction is not repliable');
return;
}

const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
// No response to the user
console.error(error);
}
},
};
const { Events } = require('discord.js');

module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;

if (!interaction.isRepliable()) {
console.log('Interaction is not repliable');
return;
}

const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
// No response to the user
console.error(error);
}
},
};
The first or second command right after starting the bot doesn't work, but after that, 90% of the commands work. Just don't use any interaction.reply(...) inside the catch block, and you'll be good. Leaving this here in case it helps anyone facing the same issue.
d.js toolkit
d.js toolkit5w ago
The thread owner has marked this issue as solved.

Did you find this page helpful?