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