Type error making a select

I was trying to implement a select as I have shown in: https://discordjs.guide/message-components/select-menus.html#building-string-select-menus I am not using SlashCommands and to see how it works, I made a simple code coping the example:
bot.client.on('messageCreate', async (event: Message): Promise<void> => {
const select = new StringSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Bulbasaur')
.setDescription('The dual-type Grass/Poison Seed Pokémon.')
.setValue('bulbasaur'),
new StringSelectMenuOptionBuilder()
.setLabel('Charmander')
.setDescription('The Fire-type Lizard Pokémon.')
.setValue('charmander'),
new StringSelectMenuOptionBuilder()
.setLabel('Squirtle')
.setDescription('The Water-type Tiny Turtle Pokémon.')
.setValue('squirtle'),
);

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

await event.reply({
content: 'Choose your starter!',
components: [row],
});
});
bot.client.on('messageCreate', async (event: Message): Promise<void> => {
const select = new StringSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Bulbasaur')
.setDescription('The dual-type Grass/Poison Seed Pokémon.')
.setValue('bulbasaur'),
new StringSelectMenuOptionBuilder()
.setLabel('Charmander')
.setDescription('The Fire-type Lizard Pokémon.')
.setValue('charmander'),
new StringSelectMenuOptionBuilder()
.setLabel('Squirtle')
.setDescription('The Water-type Tiny Turtle Pokémon.')
.setValue('squirtle'),
);

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

await event.reply({
content: 'Choose your starter!',
components: [row],
});
});
As you can see I am using typescript and the problem is in:
await event.reply({
content: 'Choose your starter!',
components: [row],
});
await event.reply({
content: 'Choose your starter!',
components: [row],
});
row give me the next type error: Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'. Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.ts(2322)
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
4 Replies
d.js toolkit
d.js toolkit4mo 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!
Gods on fire
Gods on fire4mo ago
Originally I was using: - @discordjs/builders: ^1.7.0 - @discordjs/opus: ^0.9.0 - @discordjs/rest: ^1.7.1 - discord-api-types: ^0.26.1 - discord.js: ^13.17.1 I updated discord.js to 14.14.1 version and removed the other dependencies as suggested in the docs, to see if that fixes the issues, but the error is still there. Node v: 20.11.0
d.js docs
d.js docs4mo 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)
Gods on fire
Gods on fire4mo ago
Oh perfect, it works, thanks you very much. Out of curiosity, this is something implemented after the v13.17, doesn't it? Until now I have implemented "Button Builder" and "TextInputBuilder" without using "ActionRowBuilder". Finally, selects can be used correctly in v13.17, doesn't it? Or I must update the version? I was thinking about it, but I don't have a lot leisure, now the bot is working almost perfectly. Make some improve is one thing, update the version of the bot is another thing. I have seen that are a lot of type incompatibilities, XD But I will eventually. Anyway, thank you very much for your time and attendance!