Type error when sending a container and a action row (CV2)
const container = new ContainerBuilder();
const title = new TextDisplayBuilder().setContent(
heading('🛠️ × Manages the ticket category for Test', HeadingLevel.Three),
);
const description = new TextDisplayBuilder().setContent(
'› Create, edit or delete a ticket category on this server using the menu and the button under this message.',
);
const menu = new StringSelectMenuBuilder()
.setCustomId('fadc')
.addOptions(
new StringSelectMenuOptionBuilder()
.setEmoji('🗣️')
.setValue('test')
.setLabel('ladjfkjskflj')
.setDescription('jka'),
new StringSelectMenuOptionBuilder().setEmoji('🗣️').setValue('afdtest').setLabel('ladjfkjskflj'),
new StringSelectMenuOptionBuilder().setEmoji('🗣️').setValue('teadfst').setLabel('ladjfkjskflj'),
new StringSelectMenuOptionBuilder().setEmoji('🗣️').setValue('tesaft').setLabel('ladjfkjskflj'),
new StringSelectMenuOptionBuilder().setEmoji('🗣️').setValue('testaf').setLabel('ladjfkjskflj'),
);
const row1 = new ActionRowBuilder().addComponents(menu);
container.addTextDisplayComponents(title, description);
interaction.reply({
flags: MessageFlags.IsComponentsV2,
components: [container, row1],
});
const container = new ContainerBuilder();
const title = new TextDisplayBuilder().setContent(
heading('🛠️ × Manages the ticket category for Test', HeadingLevel.Three),
);
const description = new TextDisplayBuilder().setContent(
'› Create, edit or delete a ticket category on this server using the menu and the button under this message.',
);
const menu = new StringSelectMenuBuilder()
.setCustomId('fadc')
.addOptions(
new StringSelectMenuOptionBuilder()
.setEmoji('🗣️')
.setValue('test')
.setLabel('ladjfkjskflj')
.setDescription('jka'),
new StringSelectMenuOptionBuilder().setEmoji('🗣️').setValue('afdtest').setLabel('ladjfkjskflj'),
new StringSelectMenuOptionBuilder().setEmoji('🗣️').setValue('teadfst').setLabel('ladjfkjskflj'),
new StringSelectMenuOptionBuilder().setEmoji('🗣️').setValue('tesaft').setLabel('ladjfkjskflj'),
new StringSelectMenuOptionBuilder().setEmoji('🗣️').setValue('testaf').setLabel('ladjfkjskflj'),
);
const row1 = new ActionRowBuilder().addComponents(menu);
container.addTextDisplayComponents(title, description);
interaction.reply({
flags: MessageFlags.IsComponentsV2,
components: [container, row1],
});
4 Replies
- 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 OPgives me this type error:
But the bot sends the message with no error
src/commands/slash/test.ts:44:37 - error TS2769: No overload matches this call.
Overload 1 of 3, '(options: InteractionReplyOptions & { withResponse: true; }): Promise<InteractionCallbackResponse>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.
Overload 2 of 3, '(options: InteractionReplyOptions & { fetchReply: true; }): Promise<Message<boolean>>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
Overload 3 of 3, '(options: string | MessagePayload | InteractionReplyOptions): Promise<InteractionResponse<boolean>>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
44 components: [container, row1],
src/commands/slash/test.ts:44:37 - error TS2769: No overload matches this call.
Overload 1 of 3, '(options: InteractionReplyOptions & { withResponse: true; }): Promise<InteractionCallbackResponse>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.
Overload 2 of 3, '(options: InteractionReplyOptions & { fetchReply: true; }): Promise<Message<boolean>>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
Overload 3 of 3, '(options: string | MessagePayload | InteractionReplyOptions): Promise<InteractionResponse<boolean>>', gave the following error.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIMessageTopLevelComponent | JSONEncodable<APIMessageTopLevelComponent> | TopLevelComponentData | ActionRowData<...>'.
44 components: [container, row1],
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)
thx