PaginatedMessage, Actions

I am trying to create a paginator with multiple pages (embeds) and so to paginate i want to use buttons
const paginator = new PaginatedMessage({
template: new FlanticEmbed().setFooter({
text: `${this.client.user!.username}`,
iconURL: this.client.user!.displayAvatarURL(),
}),
})
.addPageEmbeds(embeds)
.setIndex(0)
.setActions([
{
customId: "first",
emoji: "⏪",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: (context) => context.handler.setIndex(0),
},
{
customId: "previous",
emoji: "◀️",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: (context) => context.handler.setIndex(context.handler.index - 1),
},
{
customId: "next",
emoji: "▶️",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: (context) => context.handler.setIndex(context.handler.index + 1),
},
{
customId: "last",
emoji: "⏩",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: (context) =>
context.handler.setIndex(context.handler.pages.length - 1),
},
], true);

return await paginator.run(message, message.author);
const paginator = new PaginatedMessage({
template: new FlanticEmbed().setFooter({
text: `${this.client.user!.username}`,
iconURL: this.client.user!.displayAvatarURL(),
}),
})
.addPageEmbeds(embeds)
.setIndex(0)
.setActions([
{
customId: "first",
emoji: "⏪",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: (context) => context.handler.setIndex(0),
},
{
customId: "previous",
emoji: "◀️",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: (context) => context.handler.setIndex(context.handler.index - 1),
},
{
customId: "next",
emoji: "▶️",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: (context) => context.handler.setIndex(context.handler.index + 1),
},
{
customId: "last",
emoji: "⏩",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: (context) =>
context.handler.setIndex(context.handler.pages.length - 1),
},
], true);

return await paginator.run(message, message.author);
this is my snippet but this doesn't work, instead this sends the embeds, all of them at once. I must be missing something, please point it out for me so i can know what i am doing wrong
Solution:
fixed it
Jump to solution
1 Reply
Solution
Xeno
Xeno16mo ago
fixed it
Want results from more Discord servers?
Add your server