feat: add list command to retrieve and paginate user files

This commit is contained in:
grngxd 2025-07-31 20:44:22 +01:00
parent 5fd014b677
commit a5457c6cc6
6 changed files with 153 additions and 17 deletions

View file

@ -1,6 +1,7 @@
// commands/overview.ts
import { ChatInputCommandInteraction, EmbedBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
import { ChatInputCommandInteraction, MessageFlags, SlashCommandBuilder } from "discord.js";
import { db } from "../db/db";
import { createEmbed } from "../lib/embed";
import { formatSize } from "../lib/files";
import { StereoFile } from "../types/files";
@ -40,20 +41,13 @@ export const execute = async (interaction: ChatInputCommandInteraction) => {
const files = await db.all<StereoFile[]>`SELECT * FROM files WHERE owner = ${user.id}`;
const totalSize = files.reduce((a, b) => a + b.size, 0);
const embed = new EmbedBuilder()
.setColor(0xff264e)
.setAuthor({
name: `${user.globalName || "user"} on stereo`,
iconURL: user.avatarURL({ size: 512 }) || ""
})
const embed = createEmbed(user)
.setDescription("Here's your overview:")
.addFields(
{ name: "Uploads", value: `${files.length} files`, inline: true },
{ name: "Uploaded", value: `${formatSize(totalSize)} / 15 GB`, inline: true },
{ name: "Plan", value: `Free`, inline: true }
{ name: "Uploads", value: `${files.length} files`, inline: true },
{ name: "Uploaded", value: `${formatSize(totalSize)} / 15 GB`, inline: true },
{ name: "Plan", value: `Free`, inline: true }
)
.setFooter({ text: "powered by stereo" })
.setTimestamp();
await interaction.reply({ embeds: [embed] });
}