Make pages update initial embed

This commit is contained in:
Ethan Lane 2023-12-01 18:51:08 +00:00
parent a213e727c1
commit 3fc8ea3e28
2 changed files with 6 additions and 5 deletions

View file

@ -5,6 +5,6 @@ export default class TestPage extends EmbedPage {
super(embedId, page, total);
this.setTitle("Test Embed");
this.setDescription(`You are viewing page ${page}`);
this.setDescription(`You are viewing page ${page + 1}`);
}
}

View file

@ -6,19 +6,19 @@ export default class EmbedPage extends EmbedBuilder {
constructor(embedId: string, page: number, total: number) {
super();
this.setFooter({ text: `Page ${page} of ${total}`});
this.setFooter({ text: `Page ${page + 1} of ${total + 1}`});
this.row = new ActionRowBuilder<ButtonBuilder>();
this.row.addComponents(
new ButtonBuilder()
.setCustomId(`pagination ${embedId} previous`)
.setLabel("<")
.setLabel("◀️")
.setStyle(ButtonStyle.Primary)
.setDisabled(page == 0),
new ButtonBuilder()
.setCustomId(`pagination ${embedId} next`)
.setLabel(">")
.setLabel("▶️")
.setStyle(ButtonStyle.Primary)
.setDisabled(page == total));
}
@ -31,9 +31,10 @@ export default class EmbedPage extends EmbedBuilder {
}
public async sendButtonEmbed(interaction: ButtonInteraction) {
await interaction.reply({
await interaction.update({
embeds: [ this ],
components: [ this.row ],
});
return;
}
}