The reply to this interaction has already been sent or deferred (Use interaction.update > once)

Hello, to start this off:
} else if (interaction.isStringSelectMenu()) {

await interaction.update({ embeds: [rankbinds_database_embeds[0]], components: [button_action_row, interaction.message.components[0]] });
} else if (interaction.isStringSelectMenu()) {

await interaction.update({ embeds: [rankbinds_database_embeds[0]], components: [button_action_row, interaction.message.components[0]] });
I'm already updating this interaction for the first time, and if the user presses on a button, I was doing this:
await interaction.update({ embeds: [rankbinds_database_embeds[current_page]] });
await interaction.update({ embeds: [rankbinds_database_embeds[current_page]] });
But I get an error that says Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred. which I understood what it meant, so I used .editReply instead but the problem with using .editReply is that after you interact with a button it says This interaction failed. Is there any way around this?
6 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
aw0k3n
aw0k3nOP6mo ago
Forgot to attach image.
No description
aw0k3n
aw0k3nOP6mo ago
You mean this as the stacktrace?
No description
aw0k3n
aw0k3nOP6mo ago
If I use .update, the console throws that error and nothing happens to the embed. If I use .editReply, the embed does get changed and the buttons are functional but with the error message This interaction failed at the bottom of the buttons.
const button_action_row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('rankbinds_back')
.setLabel('Back')
.setStyle(ButtonStyle.Secondary),

new ButtonBuilder()
.setCustomId('rankbinds_next')
.setLabel('Next')
.setStyle(ButtonStyle.Secondary),
);

const buttons_message = await interaction.update({ embeds: [rankbinds_database_embeds[0]], components: [button_action_row, interaction.message.components[0]] });

const filter = (button) => button.customId == 'rankbinds_back' || button.customId == 'rankbinds_next';
const button_collector = buttons_message.createMessageComponentCollector({ filter, time: 100 * 1000 });

button_collector.on('collect', async (button) => {
if (button.customId == 'rankbinds_next') {
current_page += 1;

await interaction.update({ embeds: [rankbinds_database_embeds[current_page]] });

} else if (button.customId == 'rankbinds_back') {
current_page -= 1;

await interaction.update({ embeds: [rankbinds_database_embeds[current_page]] });
};
});
};
const button_action_row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('rankbinds_back')
.setLabel('Back')
.setStyle(ButtonStyle.Secondary),

new ButtonBuilder()
.setCustomId('rankbinds_next')
.setLabel('Next')
.setStyle(ButtonStyle.Secondary),
);

const buttons_message = await interaction.update({ embeds: [rankbinds_database_embeds[0]], components: [button_action_row, interaction.message.components[0]] });

const filter = (button) => button.customId == 'rankbinds_back' || button.customId == 'rankbinds_next';
const button_collector = buttons_message.createMessageComponentCollector({ filter, time: 100 * 1000 });

button_collector.on('collect', async (button) => {
if (button.customId == 'rankbinds_next') {
current_page += 1;

await interaction.update({ embeds: [rankbinds_database_embeds[current_page]] });

} else if (button.customId == 'rankbinds_back') {
current_page -= 1;

await interaction.update({ embeds: [rankbinds_database_embeds[current_page]] });
};
});
};
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
aw0k3n
aw0k3nOP6mo ago
That worked, thank you. As for not using interaction.update again, I understood that from the error message I got from the console. Just was wondering/asking if there's a way to update the message similar to interaction.update.
Want results from more Discord servers?
Add your server