mz10ah
mz10ah
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by mz10ah on 10/14/2023 in #djs-questions
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?
5 replies
DIAdiscord.js - Imagine an app
Created by mz10ah on 3/16/2023 in #djs-questions
Get interaction options values through ModalSubmitInteraction (Modal listener)
Hi I was wondering whether there is any way to retrieve interaction options (slash command options values) through ModalSubmitInteraction? The doc (https://discord.js.org/#/docs/discord.js/main/class/ModalSubmitInteraction) says nothing about it so I am guessing you can't? This is my use case: - I have two interaction listeners: One for slash commands (BaseCommandInteraction) and another for Modals (ModalSubmitInteraction). - When you use a slash command, it takes two inputs from you using options and then it pops up a modal. - The ModalSubmit event (or the whole modal itself) is handled by the Modal listener (ModalSubmitInteraction). - I want to get the values of the 2 options of slash command in Modal listener - But I am not sure the best way to do it - So does anybody know any other way to do it? Thanks in advance 🙂
15 replies