Files
Dungeons-Proxy/scripts/register-discord.js

17 lines
894 B
JavaScript

import 'dotenv/config';
import { loadConfig } from '../src/config.js';
import { DiscordBot } from '../src/bots/discord.js';
try {
const config = loadConfig();
if (!config.discord.token) throw new Error('Configure Discord in .env first.');
const bot = new DiscordBot(config);
const scope = config.discord.guildId ? `/guilds/${config.discord.guildId}` : '';
// POST upserts only /access, preserving unrelated commands registered by the owner.
await bot.api(`/applications/${config.discord.applicationId}${scope}/commands`, {
name: 'access', description: 'Request private-alpha access to Dungeons & Ground', type: 1,
...(scope ? {} : { integration_types: [0], contexts: [0, 1] }),
});
console.log(`/access registered ${scope ? 'in the configured server' : 'globally (propagation can take time)'}.`);
} catch (error) { console.error(error.message); process.exitCode = 1; }