ShardManagerOptions
Defined in: packages/sharding/src/index.ts:205
Configuration for a sharded Gateway client.
Properties
Section titled “Properties”autoScaleInterval?
Section titled “autoScaleInterval?”
optionalautoScaleInterval?:number
Defined in: packages/sharding/src/index.ts:253
Interval in milliseconds to automatically check for recommended shard count and re-scale if needed. Must be an integer >= 1000.
cluster?
Section titled “cluster?”
optionalcluster?:false|ClusterContext
Defined in: packages/sharding/src/index.ts:266
The worker contract. Read from the environment inside a worker forked by
ClusterManager; pass false to ignore it, or a context to override it.
guildCount?
Section titled “guildCount?”
optionalguildCount?:number
Defined in: packages/sharding/src/index.ts:222
The bot’s guild count for guildsPerShard, instead of asking Discord for it.
guildsPerShard?
Section titled “guildsPerShard?”
optionalguildsPerShard?:number
Defined in: packages/sharding/src/index.ts:220
A sizing hint for shardCount: "auto": run at least
ceil(guildCount / guildsPerShard) shards, and never fewer than Discord
recommends. 1 to 2500 (Discord’s limit); Discord recommends about 1000.
It only picks the shard count: Discord puts each guild on shard
(guild_id >> 22) % shardCount, so shards get about this many guilds,
not exactly, and ownership never follows from it.
handshakeTimeout?
Section titled “handshakeTimeout?”
optionalhandshakeTimeout?:number
Defined in: packages/sharding/src/index.ts:238
How long a startup round waits for its shards to send IDENTIFY/RESUME
before the next round’s spawnDelay starts. Defaults to 15000 ms.
identify?
Section titled “identify?”
optionalidentify?:false|IdentifyGate
Defined in: packages/sharding/src/index.ts:272
Where to get IDENTIFY slots. Inside a coordinated cluster this is the
parent, so the limit holds across all clusters. Pass false to pace
locally with spawnDelay instead.
intents
Section titled “intents”intents:
GatewayIntentResolvable
Defined in: packages/sharding/src/index.ts:209
Gateway intents as an array, e.g. [GatewayIntentBits.Guilds].
maxConcurrency?
Section titled “maxConcurrency?”
optionalmaxConcurrency?:number
Defined in: packages/sharding/src/index.ts:234
Shards that may IDENTIFY at once (Discord’s max_concurrency). Defaults
to the value from /gateway/bot when it was fetched (auto shard count),
else 1.
onAutoScaleError?
Section titled “onAutoScaleError?”
optionalonAutoScaleError?: (error) =>void
Defined in: packages/sharding/src/index.ts:255
Optional handler invoked when a background auto-scale check fails. Receives the thrown error.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”void
readyTimeout?
Section titled “readyTimeout?”
optionalreadyTimeout?:number
Defined in: packages/sharding/src/index.ts:251
Sequential startup: how long a shard may take to become READY before the
next one starts (a shardError reports it), in ms. Default 60000; in a
cluster worker, the parent’s identify.holdTimeout.
reconnect?
Section titled “reconnect?”
optionalreconnect?:boolean
Defined in: packages/sharding/src/index.ts:224
Gateway reconnect behavior.
shardCount?
Section titled “shardCount?”
optionalshardCount?:number|"auto"
Defined in: packages/sharding/src/index.ts:211
Number of shards. Use "auto" to request Discord’s recommended count.
shardIds?
Section titled “shardIds?”
optionalshardIds?:number[]
Defined in: packages/sharding/src/index.ts:261
The shards this manager runs, out of shardCount. Defaults to all of
them, or to the cluster’s own list inside a worker forked by
ClusterManager. Must be unique integers in [0, shardCount).
spawnDelay?
Section titled “spawnDelay?”
optionalspawnDelay?:number
Defined in: packages/sharding/src/index.ts:229
Delay between shard starts in milliseconds. Defaults to 5000 to respect Discord’s IDENTIFY rate limit (one per 5s per rate-limit key); set 0 to opt out when an external scheduler already paces the handshakes.
startup?
Section titled “startup?”
optionalstartup?:"safe"|"sequential"
Defined in: packages/sharding/src/index.ts:245
"safe" (default): start shards as fast as Discord’s IDENTIFY limits
allow. "sequential": one shard at a time, each waiting for the previous
one’s READY (up to readyTimeout) and then spawnDelay. In a cluster
worker this follows the ClusterManager’s startup option.
token:
string
Defined in: packages/sharding/src/index.ts:207
Bot token.
worker?
Section titled “worker?”
optionalworker?:false|ClusterWorker
Defined in: packages/sharding/src/index.ts:274
The worker to report to. Defaults to this process’s ClusterWorker inside a cluster.