Skip to content

autoShard()

Popii


Popii / autoShard

autoShard(options): Promise<void>

Defined in: utils/sharding.ts:86

Fetches the recommended shard count from Discord and automatically decides whether to start with a ShardingManager or single-process.

Below threshold guilds → spawns file as a normal child process (no manager overhead). At or above threshold guilds → spawns a PopiiShardingManager with the Discord-recommended shard count.

Usage in a dedicated shard.ts entry point:

import { autoShard } from "popii-framework";
await autoShard({ token: process.env.DISCORD_TOKEN!, file: "./src/index.ts" });

PopiiAutoShardOptions

Promise<void>