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