import { REST, Routes } from 'discord.js'; import { commands } from './commands'; import config from './config'; // Register all slash commands, globally across all Guilds. const commandData = Object.values(commands).map( (command) => command.data.toJSON() as any ); const rest = new REST().setToken(config.discordApiKey); try { console.log('Started refreshing application (/) commands.'); // Refresh all slash commands globally. rest.put(Routes.applicationCommands(config.discordApplicationId), { body: commandData, }); // Exit the process. process.exit(); } catch (error) { // And of course, make sure you catch and log any errors! console.error(error); }