1 file changed
+13
@@ -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}.`);
|
||||||
Reference in new issue
Block a user