ActionRowBuilder type error with EditReply

public paginationButtons(): ButtonBuilder[] {
return [
new ButtonBuilder().setCustomId('pg-prev').setLabel('Previous').setStyle(ButtonStyle.Primary).setEmoji('⬅️'),
new ButtonBuilder().setCustomId('pg-home').setLabel('Home').setStyle(ButtonStyle.Secondary).setEmoji('🏡'),
new ButtonBuilder().setCustomId('pg-next').setLabel('Next').setStyle(ButtonStyle.Primary).setEmoji('➡️'),
];
}

public async ChatInputEmbedPagination(interaction: ChatInputCommandInteraction<CacheType>, pages: EmbedBuilder[], time: number = 30 * 1000, ephemeral?: boolean): Promise<Message<boolean>> {
if (interaction.deferred || interaction.replied) {
throw new Error("Interaction already deferred or replied");
}

await interaction.deferReply({ ephemeral, fetchReply: true });

if (pages.length === 1) {
return await interaction.editReply({
embeds: pages,
components: [],
});
}

const prev = this.paginationButtons()[0].setDisabled(true);
const home = this.paginationButtons()[1].setDisabled(true);
const next = this.paginationButtons()[2].setDisabled(true);

const buttons = new ActionRowBuilder().addComponents([prev, home, next]);

let page = 0;

const msg = await interaction.editReply({
embeds: [pages[page]],
components: [buttons]
})
}
public paginationButtons(): ButtonBuilder[] {
return [
new ButtonBuilder().setCustomId('pg-prev').setLabel('Previous').setStyle(ButtonStyle.Primary).setEmoji('⬅️'),
new ButtonBuilder().setCustomId('pg-home').setLabel('Home').setStyle(ButtonStyle.Secondary).setEmoji('🏡'),
new ButtonBuilder().setCustomId('pg-next').setLabel('Next').setStyle(ButtonStyle.Primary).setEmoji('➡️'),
];
}

public async ChatInputEmbedPagination(interaction: ChatInputCommandInteraction<CacheType>, pages: EmbedBuilder[], time: number = 30 * 1000, ephemeral?: boolean): Promise<Message<boolean>> {
if (interaction.deferred || interaction.replied) {
throw new Error("Interaction already deferred or replied");
}

await interaction.deferReply({ ephemeral, fetchReply: true });

if (pages.length === 1) {
return await interaction.editReply({
embeds: pages,
components: [],
});
}

const prev = this.paginationButtons()[0].setDisabled(true);
const home = this.paginationButtons()[1].setDisabled(true);
const next = this.paginationButtons()[2].setDisabled(true);

const buttons = new ActionRowBuilder().addComponents([prev, home, next]);

let page = 0;

const msg = await interaction.editReply({
embeds: [pages[page]],
components: [buttons]
})
}
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>'.ts(2322)
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)
The package manager i use reciple has the same discord.js version as mine
3 Replies
d.js toolkit
d.js toolkit6mo ago
- 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 OP
ShompiFlen
ShompiFlen6mo ago
the action row has to be typed to its respective component that is holding for example ActionRowBuilder<ButtonBuilder>().addComponents(...)
PAdventures
PAdventures6mo ago
ok ill try this yeah that worked thank you very much 🙂