Interaction has already been acknowledged

So I'm trying to create a user context menu command, but even if I defer or reply right after the event is fired I get the error Interaction has already been acknowledged. Here's my code:
if (interaction.isUserContextMenuCommand()) {
let user = interaction.targetUser
interaction.deferReply()
//interaction(`<a:loading:998633545977299025> Loading...`);
let warns = await this.infractions.getAll(user.id)
let embed = new EmbedBuilder()
.setTitle(`<:protonModeration:988116410578370591> ${user.tag}'s Infractions`)
.setColor('#d4132d')
.setFooter({ text: 'Proton Systems | 2.0', iconURL: this.user?.displayAvatarURL() })
.setTimestamp()
embed.setDescription(warns);

interaction.editReply({ embeds: [embed], content: '' })
}
if (interaction.isUserContextMenuCommand()) {
let user = interaction.targetUser
interaction.deferReply()
//interaction(`<a:loading:998633545977299025> Loading...`);
let warns = await this.infractions.getAll(user.id)
let embed = new EmbedBuilder()
.setTitle(`<:protonModeration:988116410578370591> ${user.tag}'s Infractions`)
.setColor('#d4132d')
.setFooter({ text: 'Proton Systems | 2.0', iconURL: this.user?.displayAvatarURL() })
.setTimestamp()
embed.setDescription(warns);

interaction.editReply({ embeds: [embed], content: '' })
}
5 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.
조아오
조아오3y ago
Why do you have two ifs for the same thing? They fire one after the other That's why the error
CanineData
CanineDataOP3y ago
oh wait sorry I accidentally pasted it twice
조아오
조아오3y ago
In any point of you code before that You call defer reply or defer update?
CanineData
CanineDataOP3y ago
So there was some old code that was deferring it, but after I removed that I started getting the error The reply to this interaction has not been sent or deferred. that worked, thanks
Want results from more Discord servers?
Add your server