“The Application Did Not Respond” in Your Discord Bot: Unknown Interaction and How to Fix It
You use one of your bot's commands and Discord answers “The application did not respond” or, on a button, “This interaction failed” (the wording varies a little by language and Discord version). And the console may show Unknown interaction. It's nearly always the same thing: your bot took more than 3 seconds to answer. Here's how to work out which case is yours and how to fix it in discord.py and discord.js.
Why it happens
Discord gives your bot 3 seconds to send the first response to a command, button or menu. If it doesn't arrive in time, Discord shows the user the warning and invalidates that interaction, even if the bot is online and its response goes out a second later.
It doesn't matter that your code is fine: it's enough for it to query a website or a slow database before answering. That's why it tends to happen only sometimes, and why it can work on your PC and not somewhere else.
Rather not set it up yourself? Discord bot hosting from €1.50 a month, no contract and a full refund within 72 hours. Or create a free Discord bot, no card needed.
Check the console: each case means something different
Run the command with the console open and look for what appears right after:
Unknown interaction (code 10062): your bot answered too late. In discord.py it looks like discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction, and in discord.js like DiscordAPIError[10062]: Unknown interaction. Carry on with the next section.
Interaction has already been acknowledged (code 40060): the same thing was answered twice. We explain it further down, and it's often that your bot is running twice.
InteractionResponded in discord.py, or The reply to this interaction has already been sent or deferred. in discord.js: the same, but your library stopped it before it reached Discord.
Nothing at all: your code never gets to answer. The bot may be off, the command may still be registered but no longer exist in your code, or it may fail before responding with nothing logging it.
If it's slow: answer first and finish later
What you need to do is tell Discord you've received the command and then take your time. That's the “… is thinking” message. From there you have 15 minutes to give the final answer. It has to be the first thing the command does, before anything slow:
@bot.tree.command(name="report", description="Generate the report")
async def report(interaction: discord.Interaction):
await interaction.response.defer(thinking=True) # before anything else
text = await read_data() # this can take its time now
await interaction.followup.send(text)client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === "report") {
await interaction.deferReply(); // before anything else
const text = await readData(); // this can take its time now
await interaction.editReply(text);
}
});If the answer is private, say so at the start
Whether only the command's user sees it is decided when you defer:
defer(ephemeral=True)in discord.py anddeferReply({ flags: MessageFlags.Ephemeral })in discord.js.Answer with the right method
Once deferred, the normal reply no longer works: use
followup.send()in discord.py andeditReply()in discord.js.Pop-up forms are the exception
A form (modal) has to be the first response: you can't defer and open it afterwards. Show it before doing anything slow.
If it blocks: the failure you can't see
A bot does everything in turns. If one operation stalls it, no other interaction moves forward, which is why commands that have nothing to do with the slow one fail too.
In Python, the usual culprits are time.sleep() and requests.get(). Replace the first with await asyncio.sleep(), use aiohttp instead of requests and, if a function has no async version, run it with await asyncio.to_thread(function). The clue is this warning in the console: heartbeat blocked for more than 10 seconds.
In Node.js, the same goes for huge loops or functions ending in Sync on large data, such as fs.readFileSync or execSync.
If it says “already been acknowledged”: two responses
Check whether your bot is running twice
This is the first thing to look at. If you left a copy open on your PC and another on a host, both receive the same command and both answer. One wins and the other gets the error. Close one and try again.
Check your try/except and try/catch blocks
If you answer correctly, something fails right after and the error block tries to answer again, you get 40060. In the error block, first check whether you've already answered:
interaction.response.is_done()in discord.py andinteraction.replied || interaction.deferredin discord.js.Don't handle the same thing in two places
Two
client.onhandlers or two collectors for the same button answer twice. Keep one.
If it only happens now and then
If your code defers properly and it still fails occasionally, look at where it's running. On platforms that put programs to sleep, the first command after a while arrives while the bot's waking up (why that happens). And if the machine is short of memory or CPU, 3 seconds go by quickly.
If the warning appears and the bot is off, it's not a code bug: the command stays registered on Discord even with nobody there to answer. My bot isn't responding covers that case and the others.
If your bot is on NapNodes
Check the “Console”
Run the command and read what appears. That tells you which of the cases above you're in.
Check “Performance”
If memory or CPU are maxed out when it fails, the bot has no headroom. The free bot has 256 MB; if that's too tight, the Mini (512 MB) and Plus (1 GB) plans give you more.
Keep a single copy
If it's running here, close the one you left on your PC: two copies with the same token cause error 40060.
Press “Restart”
Do it after every code change: a bot reads its code when it starts.
Frequently asked questions
Why does my bot say “The application did not respond”?
Because it didn't answer within 3 seconds, or didn't answer at all. If it has slow work to do, defer the response right at the start: interaction.response.defer() in discord.py and interaction.deferReply() in discord.js.
What does Unknown interaction (10062) mean?
That your bot answered after the interaction had expired: the 3 seconds passed with no first response. Fix it by deferring the response at the start.
What does “Interaction has already been acknowledged” (40060) mean?
That the same thing was answered twice. Check whether your bot is running twice (on your PC and on a host) and whether your error block answers after a successful answer.
How long does a bot have to respond?
3 seconds for the first response and, if it defers, 15 minutes for the final one.
Why do my buttons stop working when the bot restarts?
Because something in memory was handling them. Use persistent views in discord.py, or handle the button by its customId in InteractionCreate in discord.js.
Can this error appear with the bot off?
Yes. The command stays registered on Discord even if your program isn't running, and with nobody to answer, the warning appears.
Shall we set it up for you?
Discord bot hosting from €1.50 a month, never oversold: your RAM is yours alone. And if you'd rather start without paying, there's a free Discord bot, no card needed.
Keep reading
- Discord Bot Not Responding (or Showing Offline): Causes and Fixes
Your Discord bot doesn't reply or shows as offline: token, Message Content Intent, permissions, error 429… Each error and its fix in discord.py and discord.js.
- My Bot's Slash Commands Aren't Showing: Syncing in discord.py and discord.js
Why your Discord bot's slash (/) commands don't appear and how to publish them: tree.sync() in discord.py, REST.put in discord.js, global or per server.
- “Missing Access” and “Missing Permissions” in Your Discord Bot: Errors 50001 and 50013
What Missing Access (50001) and Missing Permissions (50013) mean in a Discord bot, how they differ and how to fix them in discord.py and discord.js.