How to properly send components with a message?

const myRow = new ActionRowBuilder()
.addComponents(
<ButtonBuilder>,
...
)

<TextChannel>.send({embeds: [randomEmbed], components: [myRow]});
<TextChannel>.send({components: [ActionRowBuilder.from(myRow)]});
const myRow = new ActionRowBuilder()
.addComponents(
<ButtonBuilder>,
...
)

<TextChannel>.send({embeds: [randomEmbed], components: [myRow]});
<TextChannel>.send({components: [ActionRowBuilder.from(myRow)]});
I've tried both of these and I can't seem to get the appropriate type and since the official guide hasn't been updated yet, I'm really struggling with updating my existing code. Would appreciate any pointers in the right direction here. Thanks!
6 Replies
monbrey
monbrey2y ago
The first should work, but where's the message to go with it? You can't send them on their own
Torrino
Torrino2y ago
There's also an embed property as well but I've excluded it here since I thought it was irrelevant for this example. Here's the type error associated with the first example
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>'.ts(2322)
index.d.ts(229, 3): 'type' is declared here.
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>'.ts(2322)
index.d.ts(229, 3): 'type' is declared here.
Yep, can't figure it out for the life of me..
monbrey
monbrey2y ago
Do you use TypeScript
Torrino
Torrino2y ago
I do
monbrey
monbrey2y ago
ActionRowBuilder<ButtonBuilder> Try setting the generic
Torrino
Torrino2y ago
Tried that as well Here's the error Type 'ActionRowBuilder<AnyComponentBuilder>' has no signatures for which the type argument list is applicable. My mistake, I've put the generic arguments in the wrong place. Setting the generic fixed it! Thank you!!