Return the existing promise instead of erroring

This commit is contained in:
Schuyler Cebulskie
2016-09-22 23:01:37 -04:00
parent 7f652f7df8
commit 90f05a34cb

View File

@@ -97,8 +97,8 @@ class ShardingManager extends EventEmitter {
* @returns {Promise<number>}
*/
fetchGuildCount(timeout = 3000) {
if (this._guildCountPromise) return Promise.reject(new Error('Already fetching guild count.'));
if (this.shards.size !== this.totalShards) return Promise.reject(new Error('Still spawning shards.'));
if (this._guildCountPromise) return this._guildCountPromise;
this._guildCountPromise = new Promise((resolve, reject) => {
this._guildCount = 0;