mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-23 09:15:29 +01:00
Wrap guild-wise command set code in a Promise.all() to correctly wait the API to resolve
This commit is contained in:
parent
732a3bb87a
commit
0f0c3eb681
|
@ -13,6 +13,7 @@ import Config from './services/config.js';
|
||||||
import {generateDependencyReport} from '@discordjs/voice';
|
import {generateDependencyReport} from '@discordjs/voice';
|
||||||
import {REST} from '@discordjs/rest';
|
import {REST} from '@discordjs/rest';
|
||||||
import {Routes} from 'discord-api-types/v9';
|
import {Routes} from 'discord-api-types/v9';
|
||||||
|
import {Promise} from 'bluebird';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class {
|
export default class {
|
||||||
|
@ -133,12 +134,14 @@ export default class {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// If development, set commands guild-wide
|
// If development, set commands guild-wide
|
||||||
this.client.guilds.cache.each(async guild => {
|
await Promise.all(
|
||||||
|
this.client.guilds.cache.map(async guild => {
|
||||||
await rest.put(
|
await rest.put(
|
||||||
Routes.applicationGuildCommands(this.client.user!.id, guild.id),
|
Routes.applicationGuildCommands(this.client.user!.id, guild.id),
|
||||||
{body: this.commandsByName.map(command => command.slashCommand ? command.slashCommand.toJSON() : null)},
|
{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`);
|
spinner.succeed(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot%20applications.commands&permissions=2184236096`);
|
||||||
|
|
Loading…
Reference in a new issue