This is a utility class that makes multi-process sharding of a bot an easy and painless experience. It works by spawning a self-contained or for each individual shard, each containing its own instance of your bot's Client. They all have a line of communication with the master process, and there are several useful methods that utilise it in order to simplify tasks that are normally difficult with sharding. It can spawn a specific number of shards or the amount that Discord suggests for the bot, and takes a path to your main bot script to launch for each one.
Extends
EventEmitterName | Type | Optional | Description |
---|---|---|---|
file | string | No | None |
options | ShardingManagerOptions | Yes | None |
Emitted upon creating a shard.
Name | Type | Optional | Description |
---|---|---|---|
shard | Shard | No | Shard that was created |
Sends a message to all shards.
Name | Type | Optional | Description |
---|---|---|---|
message | unknown | No | Message to be sent to the shards |
Creates a single shard. Using this method is usually not necessary if you use the spawn method.
Returns
Note that the created shard needs to be explicitly spawned using its spawn method.Name | Type | Optional | Description |
---|---|---|---|
id | number | No | Id of the shard to create This is usually not necessary to manually specify. |
Fetches a client property value of each shard, or a given shard.
Example
Name | Type | Optional | Description |
---|---|---|---|
prop | string | No | Name of the client property to get, using periods for nesting |
Kills all running shards and respawns them.
Name | Type | Optional | Description |
---|---|---|---|
options | MultipleShardRespawnOptions | Yes | Options for respawning shards |
Spawns multiple shards.
Name | Type | Optional | Description |
---|---|---|---|
options | MultipleShardSpawnOptions | Yes | Options for spawning shards |