From 9583267f64b46378df61b47957496a5389d30959 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Fri, 1 Aug 2025 12:21:28 +0100 Subject: [PATCH] fix: adjust file pagination limit and improve embed formatting --- cmd/files.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/files.ts b/cmd/files.ts index 5a58e94..1e0fbf7 100644 --- a/cmd/files.ts +++ b/cmd/files.ts @@ -16,11 +16,12 @@ export const data = new SlashCommandBuilder() ); export async function renderList(user: User, userId: string, page: number): Promise { - const amount = 4; + const amount = 3; const { count } = await db.get<{ count: number }>` SELECT COUNT(*) as count FROM files WHERE owner = ${userId} `; + const totalPages = Math.max(1, Math.ceil(count / amount)); const pages = Math.max(1, Math.min(page, totalPages)); @@ -37,12 +38,16 @@ export async function renderList(user: User, userId: string, page: number): Prom const embed = createEmbed(user) .setTitle("your files") .addFields(...files.map(file => ({ - name: file.name, + name: `\`${file.name}\``, value: `${formatSize(file.size)}\n${new Date(file.created_at).toLocaleString()}\n[open in browser](${process.env.API}/${file.id})`, inline: true }))) .setFooter({ text: `page ${pages} of ${totalPages}` }); + if (totalPages <= 1) { + return { embeds: [embed] } + } + const row = new ActionRowBuilder() .addComponents( new ButtonBuilder()