Fix embed pagination buttons
This commit is contained in:
parent
7944b3aeac
commit
2a7006229a
1 changed files with 5 additions and 4 deletions
|
@ -60,7 +60,7 @@ export default class EffectHelper {
|
||||||
const effects = query[0];
|
const effects = query[0];
|
||||||
const count = query[1];
|
const count = query[1];
|
||||||
|
|
||||||
const isLastPage = Math.ceil(count / itemsPerPage) - 1 == page;
|
const totalPages = count > 0 ? Math.ceil(count / itemsPerPage) : 1;
|
||||||
|
|
||||||
let description = "*none*";
|
let description = "*none*";
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ export default class EffectHelper {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle("Effects")
|
.setTitle("Effects")
|
||||||
.setDescription(description)
|
.setDescription(description)
|
||||||
.setColor(EmbedColours.Ok);
|
.setColor(EmbedColours.Ok)
|
||||||
|
.setFooter({ text: `Page ${page} of ${totalPages}` });
|
||||||
|
|
||||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
|
@ -79,12 +80,12 @@ export default class EffectHelper {
|
||||||
.setCustomId(`effects list ${page - 1}`)
|
.setCustomId(`effects list ${page - 1}`)
|
||||||
.setLabel("Previous")
|
.setLabel("Previous")
|
||||||
.setStyle(ButtonStyle.Primary)
|
.setStyle(ButtonStyle.Primary)
|
||||||
.setDisabled(page == 0),
|
.setDisabled(page - 1 == 0),
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`effects list ${page + 1}`)
|
.setCustomId(`effects list ${page + 1}`)
|
||||||
.setLabel("Next")
|
.setLabel("Next")
|
||||||
.setStyle(ButtonStyle.Primary)
|
.setStyle(ButtonStyle.Primary)
|
||||||
.setDisabled(isLastPage),
|
.setDisabled(page == totalPages),
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue