Error while trying to preserve previous components when adding new component to an existing message

Greetings, I am trying to write a script which would append a select menu to existing components. Here is my code to do that.
const userSelect = new ChannelSelectMenuBuilder() .setCustomId('selectChannel') .setPlaceholder('Select channel(s) to share reminders in')
.setMinValues(1)
.setMaxValues(10);

const row = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(userSelect,);

const components: ActionRow<MessageActionRowComponent>[] =
interaction.message.components;

await interaction.update({ components: [...components, row] });
const userSelect = new ChannelSelectMenuBuilder() .setCustomId('selectChannel') .setPlaceholder('Select channel(s) to share reminders in')
.setMinValues(1)
.setMaxValues(10);

const row = new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(userSelect,);

const components: ActionRow<MessageActionRowComponent>[] =
interaction.message.components;

await interaction.update({ components: [...components, row] });
One challenge or error which I am facing right now is:
DiscordAPIError[50035]: Invalid Form Body
data.components[1].components[0].custom_id[COMPONENT_CUSTOM_ID_DUPLICATED]: Component custom id cannot be duplicated
DiscordAPIError[50035]: Invalid Form Body
data.components[1].components[0].custom_id[COMPONENT_CUSTOM_ID_DUPLICATED]: Component custom id cannot be duplicated
I am well aware what this error means and I feel like discord is thinking that I attempting to duplicate the old components which I am not or maybe my theory is wrong. I am not sure what other steps I could follow to achieve this objective or fix this error. Anyone got any ideas?
2 Replies
d.js toolkit
d.js toolkit14mo 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
mz10ah
mz10ahOP14mo ago
Oh interesting Alr imma have a look again Thanks you wer right lol thanks
Want results from more Discord servers?
Add your server