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

@ -3,7 +3,7 @@ import commands from "./cmd";
import { db } from "./db/db";
import { StereoFile } from "./types/files";
const client = new Client({
const bot = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
@ -14,7 +14,7 @@ const client = new Client({
const rest = new REST({ version: "10" })
.setToken(process.env.TOKEN);
client.once(Events.ClientReady, async (c) => {
bot.once(Events.ClientReady, async (c) => {
await rest.put(
Routes.applicationCommands(process.env.CLIENT_ID),
{ body: commands.map(([data, _]) => data) }
@ -29,7 +29,7 @@ client.once(Events.ClientReady, async (c) => {
console.log(c.user.tag);
});
client.on(Events.InteractionCreate, async interaction => {
bot.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;
const cmd = commands.find(([data]) => data.name === interaction.commandName);
if (!cmd) return;
@ -42,7 +42,16 @@ client.on(Events.InteractionCreate, async interaction => {
}
});
client.login(process.env.TOKEN).catch((err) => {
for (const [_, __, on] of commands) {
if (!on) continue;
for (const [event, handler] of Object.entries(on)) {
if (!Object.values(Events).includes(event as Events)) { console.warn(`Unknown event: ${event}`); continue; }
bot.on(event, handler);
}
}
bot.login(process.env.TOKEN).catch((err) => {
console.error("Failed to login:", err)
process.exit(1)
});