From 0b86b5d89175abba960db1f6137d80a05d11fe14 Mon Sep 17 00:00:00 2001 From: Aki Amane <80670461+akippnn@users.noreply.github.com> Date: Wed, 23 Apr 2025 23:55:29 +0800 Subject: [PATCH] fix(docker): Fix Dockerfile errors --- Dockerfile | 2 +- deploy-commands.js | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index bafe1f3..8a5935e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,4 @@ COPY . . ENV NODE_ENV=production -CMD [node, src/index.js] +CMD ["node", "src/index.js"] diff --git a/deploy-commands.js b/deploy-commands.js index f4ec6e4..9a1408c 100644 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -4,6 +4,9 @@ const path = require('node:path'); const logger = require('./src/utils/logger'); // Assuming logger is setup require('dotenv').config(); // Load .env variables +console.log('CLIENT_ID: ', process.env.CLIENT_ID ? 'Present' : process.env.CLIENT_ID); +console.log('DISCORD_TOKEN:', process.env.DISCORD_TOKEN ? 'Present' : process.env.DISCORD_TOKEN); + // --- Configuration --- const clientId = process.env.CLIENT_ID; const token = process.env.DISCORD_TOKEN; @@ -42,20 +45,38 @@ const rest = new REST({ version: '10' }).setToken(token); // and deploy your commands! (async () => { try { - logger.info(`Started refreshing ${commands.length} application (/) commands.`); + logger.info(`Started wiping all global and guild application (/) commands.`); - // The put method is used to fully refresh all commands in the guild with the current set - // Use Routes.applicationCommands(clientId) for global deployment - // Use Routes.applicationGuildCommands(clientId, guildId) for guild-specific deployment + // 1. Wipe Global Commands + await rest.put( + Routes.applicationCommands(clientId), + { body: [] } + ); + logger.info('Successfully wiped all global application commands.'); + + // 2. Wipe Guild Commands (optional but recommended for dev/testing guilds) + const guildId = process.env.GUILD_ID; // Make sure this is set + if (guildId) { + await rest.put( + Routes.applicationGuildCommands(clientId, guildId), + { body: [] } + ); + logger.info(`Successfully wiped all application commands in guild ${guildId}.`); + } else { + logger.warn('GUILD_ID not set; skipping guild command wipe.'); + } + + // 3. Register New Global Commands + logger.info(`Registering ${commands.length} new global commands...`); const data = await rest.put( - Routes.applicationCommands(clientId), // Deploy globally - // Routes.applicationGuildCommands(clientId, guildId), // Deploy to specific guild (for testing) + Routes.applicationCommands(clientId), { body: commands }, ); - logger.info(`Successfully reloaded ${data.length} application (/) commands globally.`); + logger.info(`Successfully registered ${data.length} new global commands.`); + } catch (error) { - // And of course, make sure you catch and log any errors! - logger.error('Failed to refresh application commands:', error); + logger.error('Failed during command reset and deployment:', error); } })(); +