Skip to content

Commit

Permalink
chore: Clean up error logging for registering Discord commands
Browse files Browse the repository at this point in the history
  • Loading branch information
PartMan7 committed Oct 29, 2024
1 parent d2bb44a commit 153537a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/discord/loaders/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ async function registerCommands() {
{}
);
log('Registering Discord commands', { globalBody, guildSpecificBody });
const results = await Promise.allSettled([
await Promise.all([
restClient.put(Routes.applicationCommands(clientId), { body: globalBody }),
...Object.entries(guildSpecificBody).map(([guildId, commands]) =>
restClient.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
restClient
.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.catch(() => log(`Unable to register commands for guild #${guildId}`))
),
]);
results.forEach(result => {
if (result.status === 'rejected') log(`Unable to register some commands`, result.reason);
});
}

export async function loadCommands(): Promise<void> {
Expand Down

0 comments on commit 153537a

Please sign in to comment.