Skip to content

ShardManagerOptions

Defined in: packages/sharding/src/index.ts:205

Configuration for a sharded Gateway client.

optional autoScaleInterval?: 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.


optional cluster?: 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.


optional guildCount?: number

Defined in: packages/sharding/src/index.ts:222

The bot’s guild count for guildsPerShard, instead of asking Discord for it.


optional guildsPerShard?: 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.


optional handshakeTimeout?: 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.


optional identify?: 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: GatewayIntentResolvable

Defined in: packages/sharding/src/index.ts:209

Gateway intents as an array, e.g. [GatewayIntentBits.Guilds].


optional maxConcurrency?: 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.


optional onAutoScaleError?: (error) => void

Defined in: packages/sharding/src/index.ts:255

Optional handler invoked when a background auto-scale check fails. Receives the thrown error.

unknown

void


optional readyTimeout?: 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.


optional reconnect?: boolean

Defined in: packages/sharding/src/index.ts:224

Gateway reconnect behavior.


optional shardCount?: number | "auto"

Defined in: packages/sharding/src/index.ts:211

Number of shards. Use "auto" to request Discord’s recommended count.


optional shardIds?: 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).


optional spawnDelay?: 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.


optional startup?: "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.


optional worker?: false | ClusterWorker

Defined in: packages/sharding/src/index.ts:274

The worker to report to. Defaults to this process’s ClusterWorker inside a cluster.