fix(docker): Fix Dockerfile errors

This commit is contained in:
Aki Amane 2025-04-23 23:55:29 +08:00
parent d4de2feaaa
commit 0b86b5d891
2 changed files with 31 additions and 10 deletions

View File

@ -12,4 +12,4 @@ COPY . .
ENV NODE_ENV=production
CMD [node, src/index.js]
CMD ["node", "src/index.js"]

View File

@ -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);
}
})();