feat(commands): add slash command deployment script

Refs: #24
This commit is contained in:
nocode committed 2026-09-13 12:25:10 +02:00
1 parent de97f878e1
commit 6b4ac374ed
1 file changed
+13
+13
View File
@@ -0,0 +1,13 @@
import { REST, Routes } from 'discord.js';
import { assertRequiredEnv, env } from '../src/config/env.js';
import { loadCommands } from '../src/core/command-loader.js';
assertRequiredEnv(['DISCORD_TOKEN', 'DISCORD_CLIENT_ID', 'DISCORD_GUILD_ID']);
const body = (await loadCommands()).map((command) => command.data.toJSON());
const rest = new REST().setToken(env.discord.token);
// Guild commands update instantly, which suits a single-server bot (M2-T05).
await rest.put(Routes.applicationGuildCommands(env.discord.clientId, env.discord.guildId), { body });
console.log(`Registered ${body.length} slash commands on guild ${env.discord.guildId}.`);