Gods on fire
Gods on fire
DIAdiscord.js - Imagine an app
Created by Gods on fire on 2/27/2024 in #djs-questions
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)
9 replies