"Interaction has already been acknowledged." error where I believe it shouldn't be possible

Hello, I have a bot where I am very occasionally getting this error (1/1000), and I am wondering if it's something I am doing wrong or maybe an error on Discord's end.
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (/root/Projects/Cat-Bot/node_modules/@discordjs/rest/dist/index.js:748:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/root/Projects/Cat-Bot/node_modules/@discordjs/rest/dist/index.js:852:23)
at async _REST.request (/root/Projects/Cat-Bot/node_modules/@discordjs/rest/dist/index.js:1293:22)
at async ChatInputCommandInteraction.deferReply (/root/Projects/Cat-Bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:129:22)
at async Object.execute (/root/Projects/Cat-Bot/commands/games/games.js:80:9)
at async Object.execute (/root/Projects/Cat-Bot/events/interactionCreate.js:59:17)
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (/root/Projects/Cat-Bot/node_modules/@discordjs/rest/dist/index.js:748:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/root/Projects/Cat-Bot/node_modules/@discordjs/rest/dist/index.js:852:23)
at async _REST.request (/root/Projects/Cat-Bot/node_modules/@discordjs/rest/dist/index.js:1293:22)
at async ChatInputCommandInteraction.deferReply (/root/Projects/Cat-Bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:129:22)
at async Object.execute (/root/Projects/Cat-Bot/commands/games/games.js:80:9)
at async Object.execute (/root/Projects/Cat-Bot/events/interactionCreate.js:59:17)
The first error was this, which means that on this line: https://github.com/TapRo7/Cat-Bot/blob/main/commands/games/games.js#L80 The interaction was somehow already responded to from somewhere else, the only possible way for it to be responded to before this is in interactionCreate.js But I have nothing there that handles chat input commands that would defer or reply to this, without returning (i.e in the cooldown handler) https://github.com/TapRo7/Cat-Bot/blob/main/events/interactionCreate.js#L59 I also got a second error as a consequence of this in the catch block in interactionCreate It was again DiscordAPIError[40060]: Interaction has already been acknowledged. at interactionCreate.js:66:25 But that also shouldn't be possible because I have a check there that if interaction.replied || interaction.deferred then it uses followUp instead so I'm not sure how the check failed and then it also failed to reply
15 Replies
d.js toolkit
d.js toolkit•13h ago
d.js docs
d.js docs•12h ago
tag suggestion for @TapRo: - DiscordAPIError: Interaction has already been acknowledged - [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred. You have already replied to the interaction. - Use <Interaction>.followUp() to send a new message - If you deferred reply it's better to use <Interaction>.editReply() - Responding to slash commands / message components
TapRo
TapRoOP•12h ago
I understand that part, I just don't know how it's happening in my code, I may be blind and not seeing something obvious but as far as I can see that interaction shouldn't get responded to twice
Mafia
Mafia•12h ago
This can also be caused if you multiple instances of your bot running
TapRo
TapRoOP•12h ago
I only run one instance on my VPS, and if there were multiple instances, the first one would've ran all the way through and the second one errored, but the bot got stuck on "Cat Bot is thinking..."
Mafia
Mafia•12h ago
Could you share the code of the command that you are running
TapRo
TapRoOP•12h ago
The code is here on the github links, would you like me to paste it here too?
Mafia
Mafia•12h ago
the first or second link
TapRo
TapRoOP•12h ago
First is the command handler, second is interactionCreate which calls it
Mafia
Mafia•12h ago
Think I got it in your interactionCreate. I'm on mobile right now so my analysis isn't necessarily the best, but it looks like you don't check if the interaction is deferred. During the cooldown response. https://github.com/TapRo7/Cat-Bot/blob/main/events%2FinteractionCreate.js#L48 No that that can't be it Ok, circling back around to your error it occurs on line 80 which is the initial defer inside of the command function. That means in your interaction create file it is responding to the interaction before the command function is run
TapRo
TapRoOP•12h ago
The cooldown checks happen before anything else and in interactionCreate there is no point before that where it could be deferred, hence I don't add the check Yes, but I'm wondering where and how it could be possible, the only thing that responds before calling execute() is the cooldown check, which if triggered returns anyway, and it would at least have a message to the user but the bot got stuck on "thinking" which means it was just deferred and nothing happened Almost feels like the Line 80 deferReply() was called twice in the same instance for no reason
Mafia
Mafia•12h ago
Here is what I think you should do. Add console.log(line number xxx) before every defer to identify which one is running Also add this to the command function defer to determine if it's running twice
TapRo
TapRoOP•12h ago
I shall try that, it's really hard to debug this because it happens so rarely, this whole week this is the first time it happened
Mafia
Mafia•11h ago
I'm sorry, I just realized that you said this is an intermittent issue. It could be an issue with your VPS But troubleshooting an issue like that is outside my scope and ability
TapRo
TapRoOP•11h ago
That's alright, I was mainly just wondering if I was missing something obvious in my code, good to see that's not the case, I appreciate your help :Prayge:

Did you find this page helpful?