Updating Select Menu

Hello, I need to refresh the select menu, so nothing would be selected and my description would be updated. I saw the only solution - interaction.update(), but then can I better maybe have the ActionRowBuilder constructor in a different file and get it when I want to update the message?
6 Replies
d.js toolkit
d.js toolkitā€¢12mo 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!
d.js docs
d.js docsā€¢12mo ago
Structures from the API cannot be edited directly. To do so, you can create a new structure (a builder) using the .from() method
const newEmbed = EmbedBuilder.from(embed).setTitle("title")
const newRow = ActionRowBuilder.from(row).addComponents(component)
const newEmbed = EmbedBuilder.from(embed).setTitle("title")
const newRow = ActionRowBuilder.from(row).addComponents(component)
PadowYT2
PadowYT2OPā€¢12mo ago
Not sure though, I have tried interaction.update({ components: ActionRowBuilder.from(select(interaction)).components });, the select function returns of the constructor of ActionRowBuilder<StringSelectMenuBuilder> But TS doesn't like it:
No overload matches this call.
Overload 1 of 2, '(options: InteractionUpdateOptions & { fetchReply: true; }): Promise<Message<true>>', gave the following error.
Type 'AnyComponentBuilder[]' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.
Type 'AnyComponentBuilder' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
Type 'ButtonBuilder' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
Type 'ButtonBuilder' is not assignable to type 'JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>>'.
The types returned by 'toJSON()' are incompatible between these types.
Type 'APIButtonComponent' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent>'.
Property 'components' is missing in type 'APIButtonComponentWithCustomId' but required in type 'APIActionRowComponent<APIMessageActionRowComponent>'.
Overload 2 of 2, '(options: string | InteractionUpdateOptions | MessagePayload): Promise<InteractionResponse<true>>', gave the following error.
Type 'AnyComponentBuilder[]' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.
No overload matches this call.
Overload 1 of 2, '(options: InteractionUpdateOptions & { fetchReply: true; }): Promise<Message<true>>', gave the following error.
Type 'AnyComponentBuilder[]' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.
Type 'AnyComponentBuilder' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
Type 'ButtonBuilder' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
Type 'ButtonBuilder' is not assignable to type 'JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>>'.
The types returned by 'toJSON()' are incompatible between these types.
Type 'APIButtonComponent' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent>'.
Property 'components' is missing in type 'APIButtonComponentWithCustomId' but required in type 'APIActionRowComponent<APIMessageActionRowComponent>'.
Overload 2 of 2, '(options: string | InteractionUpdateOptions | MessagePayload): Promise<InteractionResponse<true>>', gave the following error.
Type 'AnyComponentBuilder[]' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.
I have also tried what you told about interaction.message.components, but it isn't assignable to the types of .from() Alright, but then why won't interaction.message.components work? Should be raw data by now...? ActionRowBuilder.from(interaction.message.components).components
!Delta!
!Delta!ā€¢12mo ago
If you want embed and menu stay the same you can try interaction.update({})
PadowYT2
PadowYT2OPā€¢12mo ago
Already doing that šŸ˜‰ šŸ‘, thank you. But still having
No overload matches this call.
Overload 1 of 2, '(options: InteractionUpdateOptions & { fetchReply: true; }): Promise<Message<true>>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is missing the following properties from type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]': length, pop, push, concat, and 29 more.
Overload 2 of 2, '(options: string | InteractionUpdateOptions | MessagePayload): Promise<InteractionResponse<true>>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.ts(2769)
No overload matches this call.
Overload 1 of 2, '(options: InteractionUpdateOptions & { fetchReply: true; }): Promise<Message<true>>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is missing the following properties from type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]': length, pop, push, concat, and 29 more.
Overload 2 of 2, '(options: string | InteractionUpdateOptions | MessagePayload): Promise<InteractionResponse<true>>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.ts(2769)
await interaction.update({
components: ActionRowBuilder.from(interaction.message.components[0]!),
fetchReply: true,
});
await interaction.update({
components: ActionRowBuilder.from(interaction.message.components[0]!),
fetchReply: true,
});
d.js docs
d.js docsā€¢12mo ago
In TypeScript the ActionRowBuilder class has a generic type parameter that specifies the type of component the action row holds:
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
Want results from more Discord servers?
Add your server