aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFederico "fuji97" Rapetti <[email protected]>2022-01-13 12:59:18 +0100
committerFederico "fuji97" Rapetti <[email protected]>2022-01-13 12:59:18 +0100
commit0f0c3eb6813391917c604629ae0523da3f35f012 (patch)
treed7361999cd312ecf1ca883113cd19bba9ff6895f /src
parent732a3bb87acd1e6c8e500f1615a549b311961bea (diff)
downloadmuse-0f0c3eb6813391917c604629ae0523da3f35f012.tar.xz
muse-0f0c3eb6813391917c604629ae0523da3f35f012.zip
Wrap guild-wise command set code in a Promise.all() to correctly wait the API to resolve
Diffstat (limited to 'src')
-rw-r--r--src/bot.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/bot.ts b/src/bot.ts
index 74b56d8..cb10d1b 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -13,6 +13,7 @@ import Config from './services/config.js';
import {generateDependencyReport} from '@discordjs/voice';
import {REST} from '@discordjs/rest';
import {Routes} from 'discord-api-types/v9';
+import {Promise} from 'bluebird';
@injectable()
export default class {
@@ -133,12 +134,14 @@ export default class {
);
} else {
// If development, set commands guild-wide
- this.client.guilds.cache.each(async guild => {
- await rest.put(
- Routes.applicationGuildCommands(this.client.user!.id, guild.id),
- {body: this.commandsByName.map(command => command.slashCommand ? command.slashCommand.toJSON() : null)},
- );
- });
+ await Promise.all(
+ this.client.guilds.cache.map(async guild => {
+ await rest.put(
+ Routes.applicationGuildCommands(this.client.user!.id, guild.id),
+ {body: this.commandsByName.map(command => command.slashCommand ? command.slashCommand.toJSON() : null)},
+ );
+ }),
+ );
}
spinner.succeed(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot%20applications.commands&permissions=2184236096`);