#Can't use ActionRow as component, Type Error

7 messages · Page 1 of 1 (latest)

timber crest
#

Hey! I'm currently trying to make this code work:

import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, MessageOptions } from "discord.js";

export function getMessage(): MessageOptions {
    const embed = new EmbedBuilder().setTitle("Title").setDescription("Embed");

    const button = new ButtonBuilder().setCustomId("button").setLabel("Button");

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

    return {
        embeds: [embed],
        components: [row],
    };
}

When I try this, I get a TypeScript Error:

src/features/tickets.ts(12,22): error TS2322: 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>'.

(The error is in the line where the components are being specified in the return)

thick sandalBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

flat shore
timber crest
flat shore
#

the component type you’re trying to use

timber crest
#

Thanks! new ActionRowBuilder<ButtonBuilder>() worked! :)

flat shore
#

no prob