From 2a7006229aa0a5f3b5f61ae64f7cfe9261c96e17 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 30 Nov 2024 16:16:01 +0000 Subject: [PATCH] Fix embed pagination buttons --- src/helpers/EffectHelper.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/helpers/EffectHelper.ts b/src/helpers/EffectHelper.ts index 275e8e6..11f6ed8 100644 --- a/src/helpers/EffectHelper.ts +++ b/src/helpers/EffectHelper.ts @@ -60,7 +60,7 @@ export default class EffectHelper { const effects = query[0]; const count = query[1]; - const isLastPage = Math.ceil(count / itemsPerPage) - 1 == page; + const totalPages = count > 0 ? Math.ceil(count / itemsPerPage) : 1; let description = "*none*"; @@ -71,7 +71,8 @@ export default class EffectHelper { const embed = new EmbedBuilder() .setTitle("Effects") .setDescription(description) - .setColor(EmbedColours.Ok); + .setColor(EmbedColours.Ok) + .setFooter({ text: `Page ${page} of ${totalPages}` }); const row = new ActionRowBuilder() .addComponents( @@ -79,12 +80,12 @@ export default class EffectHelper { .setCustomId(`effects list ${page - 1}`) .setLabel("Previous") .setStyle(ButtonStyle.Primary) - .setDisabled(page == 0), + .setDisabled(page - 1 == 0), new ButtonBuilder() .setCustomId(`effects list ${page + 1}`) .setLabel("Next") .setStyle(ButtonStyle.Primary) - .setDisabled(isLastPage), + .setDisabled(page == totalPages), ); return {