Make moon count come from user setting table
All checks were successful
Test / build (push) Successful in 6s

This commit is contained in:
Ethan Lane 2024-09-27 18:15:23 +01:00
parent 9d6c2d1bb2
commit 476ff7cfc4
3 changed files with 21 additions and 3 deletions

View file

@ -1,6 +1,7 @@
import {ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, EmbedBuilder} from "discord.js";
import Moon from "../../database/entities/304276391837302787/Moon";
import EmbedColours from "../../constants/EmbedColours";
import UserSetting from "../../database/entities/UserSetting";
export default async function List(interaction: ButtonInteraction) {
if (!interaction.guild) return;
@ -23,6 +24,9 @@ export default async function List(interaction: ButtonInteraction) {
return;
}
const moonSetting = await UserSetting.FetchOneByKey(userId, "moons");
const totalMoons = moonSetting && Number(moonSetting.Value) ? Number(moonSetting.Value) : 0;
const totalPages = Math.ceil(moons[1] / pageLength);
const description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`);
@ -31,7 +35,7 @@ export default async function List(interaction: ButtonInteraction) {
.setTitle(`${member?.user.username}'s Moons`)
.setColor(EmbedColours.Ok)
.setDescription(description.join("\n"))
.setFooter({ text: `Page ${page + 1} of ${totalPages} · ${moons[1]} moons` });
.setFooter({ text: `Page ${pageNumber + 1} of ${totalPages} · ${totalMoons} moons` });
const row = new ActionRowBuilder<ButtonBuilder>()
.addComponents(