Select Menu error with Typescript

const select = new StringSelectMenuBuilder()
.setCustomId("year")
.setPlaceholder("Année scolaire")
.addOptions(
SupportedYears.map((year) =>
new StringSelectMenuOptionBuilder().setLabel(year).setValue(year)
)
);

const actionRow = new ActionRowBuilder().addComponents(select);

await interaction.reply({
content: "Select year",
components: [actionRow],
});
const select = new StringSelectMenuBuilder()
.setCustomId("year")
.setPlaceholder("Année scolaire")
.addOptions(
SupportedYears.map((year) =>
new StringSelectMenuOptionBuilder().setLabel(year).setValue(year)
)
);

const actionRow = new ActionRowBuilder().addComponents(select);

await interaction.reply({
content: "Select year",
components: [actionRow],
});
While trying to add a select menu to my discordjs slash command interaction ( type ChatInputCommandInteraction ), it says that : No overhead corresponds to this call. The 1 of 2 overload, '(options: InteractionReplyOptions & { fetchReply: true; }): Promise<Message<boolean>>', produced the following error. Unable to assign type 'ActionRowBuilder<AnyComponentBuilder>' to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'. The 'type' property is absent in the 'ActionRowBuilder<AnyComponentBuilder>' type but required in the 'ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>'. The 2 of 2 overload, '(options: string | InteractionReplyOptions | MessagePayload): Promise<InteractionResponse<boolean>>', produced the following error. Unable to assign type 'ActionRowBuilder<AnyComponentBuilder>' to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.ts(2769) Any idea why I have this error ?
3 Replies
d.js toolkit
d.js toolkit12mo 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 staff
d.js docs
d.js docs12mo ago
Tag suggestion for @XandoR: 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)
XandoR
XandoROP12mo ago
@chewie 🎅 worked, thx
Want results from more Discord servers?
Add your server