export class ShardClientUtil
Helper class for sharded clients spawned as a child process/worker, such as from a ShardingManager. Utilises IPC to send and receive data to/from the master process and other shards.
Client client :
Client for the shard
readonlynumber count :
Total number of shards
readonlynumber[] ids :
Array of shard ids of this client
ShardingManagerMode mode :
Mode the shard was spawned with
MessagePort | null parentPort :
Message port for the master process (only when mode is worker
)
Overload 1
Overload 2
Overload 3
Overload 4
broadcastEvalResult
>() : Promise<Serialized<Result>[]> <
Result
Evaluates a script or function on all shards, or a given shard, in the context of the Clients.
Examples:
client.shard.broadcastEval(client => client.guilds.cache.size)
.then(results => console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`))
.catch(console.error);
Returns: Results of the script execution
Overload 1
Overload 2
respawnAlloptions?: MultipleShardRespawnOptions) : Promise<void> (
options?: MultipleShardRespawnOptions
Requests a respawn of all shards.
Returns: Resolves upon the message being sent
Get the shard id for a given guild id.
static singletonclient: Client<true>mode: ShardingManagerMode) : ShardClientUtil (
client: Client<true>
mode: ShardingManagerMode
Creates/gets the singleton of this class.