fix: More input validation in deploying system commands

This commit is contained in:
Marius Begby committed 2023-07-19 16:54:35 +02:00
1 parent 3292c889ec
commit 85cfad8e51
1 file changed
+10 -3
+10 -3
View File
@@ -24,6 +24,11 @@ for (const folder of commandFolders) {
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN); const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN);
(async () => { (async () => {
if (!process.env.DISCORD_APPLICATION_ID || !process.env.DISCORD_BOT_TOKEN) {
logger.error('Missing required environment variables for deployment.');
logger.error('Provide valid DISCORD_APPLICATION_ID and DISCORD_BOT_TOKEN in .env file.');
}
try { try {
logger.info('DEPLOYING BOT SLASH COMMANDS'); logger.info('DEPLOYING BOT SLASH COMMANDS');
logger.info( logger.info(
@@ -48,16 +53,18 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
logger.info('Started refreshing application (/) system commands.'); logger.info('Started refreshing application (/) system commands.');
const systemGuildIds = systemOptions.systemGuildIds; const systemGuildIds = systemOptions.systemGuildIds;
await Promise.all( await Promise.all(
systemGuildIds.map((systemGuildId) => systemGuildIds.map((systemGuildId) => {
logger.info(`Refreshing system commands for guild id: ${systemGuildId}.`);
refreshCommands( refreshCommands(
Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, systemGuildId), Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, systemGuildId),
systemCommands systemCommands
) );
) })
); );
logger.info('Successfully refreshed application (/) system commands.'); logger.info('Successfully refreshed application (/) system commands.');
} catch (error) { } catch (error) {
logger.error(error, 'Failed to refresh application (/) system commands.'); logger.error(error, 'Failed to refresh application (/) system commands.');
logger.error('Make sure the bot is in the system guilds provided.');
} }
})(); })();