BaseMessageOptions#components does not take Builders
Hey everyone, so I've just downloaded djs 14.7.0 and i'm migrating my bot. I used to have a few
.send({ components: [myComp] })
.send({ components: [myComp] })
, where
myComp
myComp
was the equivalent of what is now a Builder. So now i've updated it to a builder, but it is no longer accepted by TypeScript. A few examples:
src/commands/General/code.ts:169:86 - 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<MessageActionRowComponentData | MessageActionRowComponentBuilder>'.169 await prompter.send({ components: [codeMenu(codes)] });
src/commands/General/code.ts:169:86 - 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<MessageActionRowComponentData | MessageActionRowComponentBuilder>'.169 await prompter.send({ components: [codeMenu(codes)] });
src/commands/General/code.ts:211:20 - error TS2322: Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.211 components: [wrapConfirmation],
src/commands/General/code.ts:211:20 - error TS2322: Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.211 components: [wrapConfirmation],
How can I solve this? Calling .data or .toJSON() does not solve the issue
Thanks!
Solution
Found it, my action rows need to have a generic set, i cannot use the broad ActionRowBuilder.