diff --git a/aethex-bot/scripts/register-commands.js b/aethex-bot/scripts/register-commands.js index 9f72df0..03076a3 100644 --- a/aethex-bot/scripts/register-commands.js +++ b/aethex-bot/scripts/register-commands.js @@ -110,19 +110,44 @@ const commands = [ }, ]; -const token = process.env.DISCORD_BOT_TOKEN || process.env.DISCORD_TOKEN; +const token = process.env.DISCORD_BOT_TOKEN; +const clientId = process.env.DISCORD_CLIENT_ID; + +if (!token) { + console.error('Missing DISCORD_BOT_TOKEN'); + process.exit(1); +} + +if (!clientId) { + console.error('Missing DISCORD_CLIENT_ID'); + process.exit(1); +} + const rest = new REST({ version: '10' }).setToken(token); (async () => { try { - console.log('Registering slash commands...'); + console.log('Fetching existing commands...'); + + const existingCommands = await rest.get( + Routes.applicationCommands(clientId) + ); + + console.log(`Found ${existingCommands.length} existing commands`); + + const entryPointCommands = existingCommands.filter(cmd => cmd.type === 4); + + const allCommands = [...commands, ...entryPointCommands]; + + console.log(`Registering ${commands.length} commands (preserving ${entryPointCommands.length} entry points)...`); const data = await rest.put( - Routes.applicationCommands(process.env.DISCORD_CLIENT_ID), - { body: commands } + Routes.applicationCommands(clientId), + { body: allCommands } ); console.log(`Successfully registered ${data.length} commands`); + data.forEach(cmd => console.log(` - /${cmd.name}`)); } catch (error) { console.error('Error registering commands:', error); }