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:
[continues]
18 Replies
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:
register.js:
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.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 responsesbecause of the 3 seconds thing
How do I check that
If that could be the problem
the change:
the logs:
Try killing the bot and then execute the command while the bot is offline
got the same:
"The application did not respond",
why would this help?
Unknown Interaction is also caused by replying twice
Running multiple instances of the bot is a common culprit
Use deferReply
And instead of using interaction.reply use interaction.editReply
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
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
yeah, it doesn't work either
Using deferReply like that prevents you from using other responses in the command like showModal
Oh, I see, thanks, and sorry for giving a bad answer
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?
no, i am running it locally
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?
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
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:
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.The thread owner has marked this issue as solved.