#DiscordAPIError[40060] Interaction has already been acknowledged.

25 messages · Page 1 of 1 (latest)

reef mica
#
await axios.get(`...`) // Search in Google //
  .then((response) => {
      return await interaction.reply({ // (*) //
        content: "Test1"
      }) 
  }).catch(async (error) => {
    return await interaction.reply({
      content: "Test1",
      ephemeral: true
    })
  });

Why I sometimes get an error DiscordAPIError[40060]: Interaction has already been acknowledged.? The error points to the string (*)

tired riverBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

pseudo hound
#

further up in your code you maybe used interaction.reply already

#

if you use interaction.reply once

#

you need to followup with either interaction.editReply

#

or interaction.followUp

#

depending on whether you want to edit the msg you sent or send another msg replying to your first msg

reef mica
#

@pseudo hound this is all code, I didn't used interaction.reply() anywhere else

pseudo hound
#

whats above interaction.reply

#

theres a couple things that could count as acknowledging an interaction

#

the point is something is getting to respond to your interaction before your interaction.reply

reef mica
#

I don't even know what the reason is.
this is all the code of my command, I make a google query and try to send "Test1" if the query is successful. Otherwise it is "Test2". Basically everything happens fine, but every 30 minutes / once an hour this error appears.

pseudo hound
#

oh

#

try doing await interaction.deferReply()

#

before your axios call

#

and then interaction.editReply

#

for your response

reef mica
# pseudo hound try doing await interaction.deferReply()

Good idea, thank you.
I just read in the official discord.js guide this:

you have three seconds to respond to an interaction before its token becomes invalid.

do you think this could be related to my problem? (the promise doesn't get done in 3 seconds)

pseudo hound
#

yea

#

that interactionr esponded error means

#

your axios call took longer than 3 seconds

#

and you didnt defer it

#

so the interaction expired

#

and so you cant reply to it

reef mica
#

thanks again!