#Help with typescript?

1 messages · Page 1 of 1 (latest)

brittle star
#
const row = new ActionRowBuilder().addComponents(
            new ButtonBuilder().setCustomId("invite").setLabel("Invite").setStyle(ButtonStyle.Primary)
        );

await interaction.reply({ embeds: [embed], components: [row] });

row gets underlined and gives an error:

  Overload 1 of 2, '(options: InteractionReplyOptions & { fetchReply: true; }): Promise<Message<boolean>>', gave the following 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<MessageActionRowComponentData | MessageActionRowComponentBuilder>'.
  Overload 2 of 2, '(options: string | InteractionReplyOptions | MessagePayload): Promise<InteractionResponse<boolean>>', gave the following error.
    Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.ts(2769)
index.d.ts(260, 3): 'type' is declared here.
hybrid dirgeBOT
#

Suggestion for @brittle star:
guide Interactions: Building and sending buttons
To create your buttons, use the ActionRowBuilderopen in new window and ButtonBuilderopen in new window classes. Then, pass the resulting row object to ChatInputCommandInteraction#replyopen in new window in the components array of InteractionReplyOptionsopen in new window:
read more

shy lintel
#

The yellow warning box applies to you

hybrid dirgeBOT
#

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)
brittle star
#

oh