Add untracked counter
All checks were successful
Test / build (push) Successful in 6s

This commit is contained in:
Ethan Lane 2024-10-29 10:49:09 +00:00
parent 8b0e93d324
commit 866beb0e04
4 changed files with 22 additions and 9 deletions

View file

@ -29,7 +29,18 @@ export default async function List(interaction: ButtonInteraction) {
const totalPages = Math.ceil(moons[1] / pageLength);
const description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`);
let description = ["*none*"];
if (moons[0].length > 0) {
description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`);
}
const moonDifference = totalMoons - moons[1];
const isLastPage = pageNumber + 1 == totalPages || moons[0].length == 0;
if (isLastPage && moonDifference > 0) {
description.push(`...plus ${moonDifference} more untracked`);
}
const embed = new EmbedBuilder()
.setTitle(`${member?.user.username}'s Moons`)
@ -48,7 +59,7 @@ export default async function List(interaction: ButtonInteraction) {
.setCustomId(`moons list ${userId} ${pageNumber + 1}`)
.setLabel("Next")
.setStyle(ButtonStyle.Primary)
.setDisabled(pageNumber + 1 == totalPages));
.setDisabled(isLastPage));
await interaction.update({
embeds: [ embed ],