fix: adjust file pagination limit and improve embed formatting

This commit is contained in:
grngxd 2025-08-01 12:21:28 +01:00
parent 0fda50dfb5
commit 9583267f64

View file

@ -16,11 +16,12 @@ export const data = new SlashCommandBuilder()
);
export async function renderList(user: User, userId: string, page: number): Promise<InteractionReplyOptions> {
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<ButtonBuilder>()
.addComponents(
new ButtonBuilder()