const fs = require('fs'); const { REST, Routes } = require('discord.js'); require('dotenv').config(); const path = require('node:path'); const commands = []; const commandsPath = path.join(__dirname, 'commands'); const commandFiles = fs.readdirSync(commandsPath).filter(file => !file.includes('WIP')); for (const file of commandFiles) { const command = require(`./commands/${file}`); commands.push(command.data.toJSON()); } const rest = new REST({ version: '10' }).setToken(process.env.TOKEN); (async () => { try { console.log(`Started refreshing ${commands.length} application (/) commands.`); const data = await rest.put( Routes.applicationCommands(process.env.debugId), { body: commands }, ); console.log(`Successfully reloaded ${data.length} application (/) commands.`); } catch (error) { console.error(error); } })();