export class Shard extends EventEmitterA self-contained shard created by the ShardingManager. Each one has a ChildProcess that contains an instance of the bot and its Client. When its child process/worker exits for any reason, the shard will spawn a new one to replace it as necessary.
args : string[]
Arguments for the shard's process/worker
env : unknown
Environment variables for the shard's process, or workerData for the shard's worker
execArgv : string[]
Arguments for the shard's process/worker executable
id : number
The shard's id in the manager
manager : ShardingManager
Manager that created the shard
process : ChildProcess | null
Process of the shard (if mode is process)
Fetches a client property value of the shard.
shard.fetchClientValue('guilds.cache.size')
.then(count => console.log(`${count} guilds in shard ${shard.id}`))
.catch(console.error);kill() : void
Immediately kills the shard's process/worker and does not restart it.
on<Event extends keyof ShardEventTypes
>(event: Eventlistener: (...args: ShardEventTypes[Event]) => void) : this
Event extends keyof ShardEventTypes
once<Event extends keyof ShardEventTypes
>(event: Eventlistener: (...args: ShardEventTypes[Event]) => void) : this
Event extends keyof ShardEventTypes
respawn() : Promise<ChildProcess>
Kills and restarts the shard's process/worker.
spawn(timeout?: number) : Promise<ChildProcess>
Forks a child process or creates a worker thread for the shard. You should not need to call this manually.
death(process: ChildProcess | Worker)
Emitted upon the shard's child process/worker exiting.
Emitted upon the shard's shardDisconnect event.
message(message: any)
Emitted upon receiving a message from the child process/worker.
Emitted upon the shard's shardReconnecting event.
Emitted upon the shard's shardResume event.
spawn(process: ChildProcess | Worker)
Emitted upon the creation of the shard's child process/worker.