export class ShardClientUtilHelper 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
readonlycount : number
Total number of shards
readonlyids : number[]
Array of shard ids of this client
mode : ShardingManagerMode
Mode the shard was spawned with
parentPort : MessagePort | null
Message port for the master process (only when mode is worker)
Overload 1
Overload 2
Overload 3
Overload 4
broadcastEval<Result
>() : 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
respawnAll(options?: 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 singleton(client: Client<true>mode: ShardingManagerMode) : ShardClientUtil
client: Client<true>
mode: ShardingManagerMode
Creates/gets the singleton of this class.