fix: Small changes to deploying system commands

This commit is contained in:
Marius Begby committed 2023-07-19 16:48:00 +02:00
1 parent 4e8145151f
commit 3292c889ec
1 file changed
+16 -17
+16 -17
View File
@@ -27,17 +27,12 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
try { try {
logger.info('DEPLOYING BOT SLASH COMMANDS'); logger.info('DEPLOYING BOT SLASH COMMANDS');
logger.info( logger.info(
slashCommands.map((command) => { slashCommands.map((command) => command.name),
return command.name;
}),
'Bot commands found:' 'Bot commands found:'
); );
logger.info('Started refreshing application (/) bot commands.'); logger.info('Started refreshing application (/) bot commands.');
await rest.put(Routes.applicationCommands(process.env.DISCORD_APPLICATION_ID), { await refreshCommands(Routes.applicationCommands(process.env.DISCORD_APPLICATION_ID), slashCommands);
body: slashCommands
});
logger.info('Successfully refreshed application (/) bot commands.'); logger.info('Successfully refreshed application (/) bot commands.');
} catch (error) { } catch (error) {
logger.error(error, 'Failed to refresh application (/) bot commands.'); logger.error(error, 'Failed to refresh application (/) bot commands.');
@@ -46,22 +41,26 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
try { try {
logger.info('DEPLOYING SYSTEM SLASH COMMANDS'); logger.info('DEPLOYING SYSTEM SLASH COMMANDS');
logger.info( logger.info(
systemCommands.map((systemCommand) => { systemCommands.map((systemCommand) => systemCommand.name),
return systemCommand.name;
}),
'System commands found:' 'System commands found:'
); );
logger.info('Started refreshing application (/) system commands.'); logger.info('Started refreshing application (/) system commands.');
for (const systemGuildId of systemOptions.systemGuildIds) { const systemGuildIds = systemOptions.systemGuildIds;
logger.info(`Refreshing system commands for guild id ${systemGuildId}.`); await Promise.all(
await rest.put(Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, systemGuildId), { systemGuildIds.map((systemGuildId) =>
body: systemCommands refreshCommands(
}); Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, systemGuildId),
} 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.');
} }
})(); })();
async function refreshCommands(route, commands) {
await rest.put(route, { body: commands });
}