Editing a message to insert a new component gives "Interaction failed" message?

Pretty simple thing here. Within my Discord bot, after a user successfully selects an option from a StringSelectMenu that the bot sends to them, in the code I have the bot .edit() the message that contained the StringSelectMenu in it that the user just chose from.
const firstMessage = await interaction.reply({content:'Blah blah blah choose an option', components:[actionRow]});
const checkUserFilter = i => i.user.id === interaction.user.id;
const choiceSelected = await firstMessage.awaitMessageComponent({ filter: checkUserFilter, time: 60000 });

if (choiceSelected.values[0] == "someOption") {
const channelSelect = new ChannelSelectMenuBuilder({ custom_id: 'channelSelect', placeholder: 'Select a channel'});
const channelSelectActionRow = new ActionRowBuilder().addComponents(channelSelect);

const chooseChannelMsg = await firstMessage.edit({ content: 'Now I am asking you to choose a channel!', components:[channelSelectActionRow]});
const firstMessage = await interaction.reply({content:'Blah blah blah choose an option', components:[actionRow]});
const checkUserFilter = i => i.user.id === interaction.user.id;
const choiceSelected = await firstMessage.awaitMessageComponent({ filter: checkUserFilter, time: 60000 });

if (choiceSelected.values[0] == "someOption") {
const channelSelect = new ChannelSelectMenuBuilder({ custom_id: 'channelSelect', placeholder: 'Select a channel'});
const channelSelectActionRow = new ActionRowBuilder().addComponents(channelSelect);

const chooseChannelMsg = await firstMessage.edit({ content: 'Now I am asking you to choose a channel!', components:[channelSelectActionRow]});
Everything runs fine, and the bot correctly edits the firstMessage message and moves on. (It edits firstMessage by providing new text and new, separate ChannelSelectMenu.) But even though everything was correct and the message gets edited, the user still sees the warning "Interaction failed" in the Discord UI. I have no idea why this warning is being thrown, as everything is running successfully and there are not crashes? How do I ensure "Interaction failed" is not displayed to the user after they select an option from the initial StringSelectMenu (in firstMessage)?
12 Replies
d.js toolkit
d.js toolkit8mo 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! - Marked as resolved by OP
treble/luna
treble/luna8mo ago
editing the message does not acknowlegde the interaction so you either have to reply, or if the interaction happened on the message you are trying to edit, call <Interaction>.update
2Flow2
2Flow28mo ago
Oh, I see. So if I use <Interaction>.update on firstMessage, it will register that the interaction was responded to?
treble/luna
treble/luna8mo ago
no firstMessage is not an Interaction
2Flow2
2Flow28mo ago
Right. That's what I thought would be the issue. So I'd need to grab the interaction of the user clicking a specific Select menu option?
treble/luna
treble/luna8mo ago
you have it choiceSelected
2Flow2
2Flow28mo ago
And then use .update() on that interaction? (In this case choiceSelected, right?)
treble/luna
treble/luna8mo ago
yes do actually pass params into the update though
2Flow2
2Flow28mo ago
Okay, cool, that's what I thought too. Thanks, lemme try that. Sorry, what do you mean by this?
treble/luna
treble/luna8mo ago
replace your edit with update
2Flow2
2Flow28mo ago
Fantastic, that seems to have worked! Thanks so much for helping to clear up the difference between those two! 💚 You've really improved my day. So seriously, thanks for your time.
treble/luna
treble/luna8mo ago
you're welcome!