#!/usr/bin/env node // Register slash commands without starting the bot. // node scripts/register-commands.js → guild-scoped for cfg.guildIds, else global // node scripts/register-commands.js --global → global // node scripts/register-commands.js --clear → remove them (same scope rules) const { REST, Routes } = require('discord.js'); const { loadConfig } = require('../src/config'); const { commandDefs } = require('../src/bot/commands'); async function main() { const cfg = loadConfig(); const args = process.argv.slice(2); const body = args.includes('--clear') ? [] : commandDefs; const rest = new REST({ version: '10' }).setToken(cfg.token); const guilds = args.includes('--global') ? [] : cfg.guildIds || []; if (guilds.length) { for (const g of guilds) { const res = await rest.put(Routes.applicationGuildCommands(cfg.applicationId, g), { body }); console.log(`guild ${g}: ${res.length} commands`); } } else { const res = await rest.put(Routes.applicationCommands(cfg.applicationId), { body }); console.log(`global: ${res.length} commands (may take up to an hour to appear)`); } } main().catch((e) => { console.error(e); process.exit(1); });