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 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() const embed = new EmbedBuilder()
.setTitle(`${member?.user.username}'s Moons`) .setTitle(`${member?.user.username}'s Moons`)
@ -48,7 +59,7 @@ export default async function List(interaction: ButtonInteraction) {
.setCustomId(`moons list ${userId} ${pageNumber + 1}`) .setCustomId(`moons list ${userId} ${pageNumber + 1}`)
.setLabel("Next") .setLabel("Next")
.setStyle(ButtonStyle.Primary) .setStyle(ButtonStyle.Primary)
.setDisabled(pageNumber + 1 == totalPages)); .setDisabled(isLastPage));
await interaction.update({ await interaction.update({
embeds: [ embed ], embeds: [ embed ],

View file

@ -22,6 +22,13 @@ export default async function ListMoons(interaction: CommandInteraction) {
description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`); description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`);
} }
const moonDifference = totalMoons - moons[1];
const isLastPage = page + 1 == totalPages || moons[0].length == 0;
if (isLastPage && moonDifference > 0) {
description.push(`...plus ${moonDifference} more untracked`);
}
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setTitle(`${user.username}'s Moons`) .setTitle(`${user.username}'s Moons`)
.setColor(EmbedColours.Ok) .setColor(EmbedColours.Ok)
@ -39,7 +46,7 @@ export default async function ListMoons(interaction: CommandInteraction) {
.setCustomId(`moons list ${user.id} ${page + 1}`) .setCustomId(`moons list ${user.id} ${page + 1}`)
.setLabel("Next") .setLabel("Next")
.setStyle(ButtonStyle.Primary) .setStyle(ButtonStyle.Primary)
.setDisabled(page + 1 == totalPages || moons[0].length == 0)); .setDisabled(isLastPage));
await interaction.reply({ await interaction.reply({
embeds: [ embed ], embeds: [ embed ],

View file

@ -1,5 +0,0 @@
import DefaultValues from "../constants/DefaultValues";
import UserSetting from "../database/entities/UserSetting";
export default class UserSettingsHelper {
}