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 {
logger.info('DEPLOYING BOT SLASH COMMANDS');
logger.info(
slashCommands.map((command) => {
return command.name;
}),
slashCommands.map((command) => command.name),
'Bot commands found:'
);
logger.info('Started refreshing application (/) bot commands.');
await rest.put(Routes.applicationCommands(process.env.DISCORD_APPLICATION_ID), {
body: slashCommands
});
await refreshCommands(Routes.applicationCommands(process.env.DISCORD_APPLICATION_ID), slashCommands);
logger.info('Successfully refreshed application (/) bot commands.');
} catch (error) {
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 {
logger.info('DEPLOYING SYSTEM SLASH COMMANDS');
logger.info(
systemCommands.map((systemCommand) => {
return systemCommand.name;
}),
systemCommands.map((systemCommand) => systemCommand.name),
'System commands found:'
);
logger.info('Started refreshing application (/) system commands.');
for (const systemGuildId of systemOptions.systemGuildIds) {
logger.info(`Refreshing system commands for guild id ${systemGuildId}.`);
await rest.put(Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, systemGuildId), {
body: systemCommands
});
}
const systemGuildIds = systemOptions.systemGuildIds;
await Promise.all(
systemGuildIds.map((systemGuildId) =>
refreshCommands(
Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, systemGuildId),
systemCommands
)
)
);
logger.info('Successfully refreshed application (/) system commands.');
} catch (error) {
logger.error(error, 'Failed to refresh application (/) system commands.');
}
})();
async function refreshCommands(route, commands) {
await rest.put(route, { body: commands });
}