Even if interaction is not replied - Interaction has already been acknowledged

I check both this.interaction.replied || !this.interaction.isRepliable() before replying to an interaction, but I still get Interaction has already been acknowledged. Is this a bug?
if (this.interaction.replied || !this.interaction.isRepliable()) {
return;
}

// I get this RANDOMLY here: DiscordAPIError[40060]: Interaction has already been acknowledged.
await this.interaction.reply({ content: content, ephemeral: ephemeral });
if (this.interaction.replied || !this.interaction.isRepliable()) {
return;
}

// I get this RANDOMLY here: DiscordAPIError[40060]: Interaction has already been acknowledged.
await this.interaction.reply({ content: content, ephemeral: ephemeral });
8 Replies
d.js docs
d.js docs3y ago
• 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.
LeMorrow
LeMorrowOP3y ago
I know the issue happens when you reply twice, but I cannot possible see how that could be the case, unless it's some race condition. I don't get it every time (only sometimes, haven't figured out a pattern). And I figured that this should still make sure it doesn't happen regardless?
MrMythical
MrMythical3y ago
interaction.replied is not reliable (at least for this) and isRepliable only checks for interaction type btw
LeMorrow
LeMorrowOP3y ago
I see I guess I'm going insane, I can't figure out for the life of me how this could occur. Some kind of weird async race condition I guess
MrMythical
MrMythical3y ago
.replied or .deferred are set after it's replied or deferred. If you do the code below, you'll most likely get an error, because the first reply isn't awaited
interaction.reply("...")
if (!interaction.replied) interaction.reply("...")
interaction.reply("...")
if (!interaction.replied) interaction.reply("...")
LeMorrow
LeMorrowOP3y ago
yea I don't think I'm missing any awaits ¯\_(ツ)_/¯
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
⸸⛧Stealth⛧⸸
Most likely two instances of your bot are running
Want results from more Discord servers?
Add your server