import { ActivityType, Client, Events, GatewayIntentBits, REST, Routes } from "discord.js"; import user from "./cmd/user"; import { db } from "./db"; import { StereoFile } from "./types"; const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, ] }); const rest = new REST({ version: "10" }).setToken(process.env.TOKEN); client.once(Events.ClientReady, async (c) => { await rest.put( Routes.applicationCommands(process.env.CLIENT_ID), { body: commands.map(([data]) => data) } ); const files = (await db.all`SELECT * FROM files`).length c.user.setPresence({ activities: [{ name: `${files} files uploaded to stereo`, type: ActivityType.Custom }], status: "dnd" }); console.log(c.user.tag); }); const commands = [ user ] client.on(Events.InteractionCreate, async interaction => { if (!interaction.isChatInputCommand()) return; const cmd = commands.find(([data]) => data.name === interaction.commandName); if (!cmd) return; try { await cmd[1](interaction); } catch (err) { console.error(err); await interaction.reply({ content: "there was an error executing this command", ephemeral: true }); } }); client.login(process.env.TOKEN).catch((err) => { console.error("Failed to login:", err) process.exit(1) });