"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.
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 reply15 Replies
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 componentsI 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
This can also be caused if you multiple instances of your bot running
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..."
Could you share the code of the command that you are running
The code is here on the github links, would you like me to paste it here too?
the first or second link
First is the command handler, second is interactionCreate which calls it
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
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 twiceI 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
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
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: