/** * @file Enregistre les commandes slash auprès de Discord pour le serveur configuré (`npm run deploy`), * à relancer après l'ajout d'une commande ou un changement de ses options. */ import { REST, Routes } from "discord.js"; import { config } from "./src/config.js"; import { loadCommands } from "./src/loadCommands.js"; const commands = (await loadCommands()).map((command) => command.data.toJSON()); const rest = new REST().setToken(config.token); (async () => { try { console.log( `Started refreshing ${commands.length} application (/) commands.` ); const data = await rest.put( Routes.applicationGuildCommands( config.applicationId, config.discordGuildId ), { body: commands } ); console.log( `Successfully reloaded ${data.length} application (/) commands.` ); } catch (error) { console.error(error); process.exitCode = 1; } })();