Add shard eval, broadcastEval, and fix fetchGuildCount response

This commit is contained in:
Schuyler Cebulskie
2016-09-24 01:21:41 -04:00
parent 65b93532ce
commit e4f416ae6c
4 changed files with 52 additions and 2 deletions

View File

@@ -114,6 +114,17 @@ class ShardingManager extends EventEmitter {
return Promise.all(promises);
}
/**
* Evaluates a script on all shards, in the context of the Clients.
* @param {string} script JavaScript to run on each shard
* @returns {Promise<Array>} Results of the script
*/
broadcastEval(script) {
const promises = [];
for (const shard of this.shards.values()) promises.push(shard.eval(script));
return Promise.all(promises);
}
/**
* Obtains the total guild count across all shards.
* @param {number} [timeout=3000] Time to automatically fail after (in milliseconds)