// commands.js const fs = require('node:fs'); const path = require('node:path'); const { REST } = require('discord.js'); const { Routes } = require('discord-api-types/v10'); const { clientId, guildId, token } = require('./config.json'); const lawcodesCommand = require('./commands/lawcodes'); const commands = [lawcodesCommand.data.toJSON()]; const rest = new REST({ version: '10' }).setToken(token); (async () => { try { // Step 1: Clear all existing commands await rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] }); console.log('✅ Cleared all existing commands.'); // Step 2: Deploy only the current lawcodes command const data = await rest.put( Routes.applicationGuildCommands(clientId, guildId), { body: commands } ); console.log(`✅ Successfully deployed ${data.length} command(s).`); } catch (error) { console.error('❌ Error during command deployment:', error); } })();