Skip to content

harmonixjs/shard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@harmonixjs/shard

Automated multi-process sharding for HarmonixJS.

Discord requires sharding at 2,500 guilds. It can still be enabled earlier for operational reasons.

Create a parent launcher:

// src/shard.ts
import { resolve } from "path";
import { HarmonixShardingManager } from "@harmonixjs/shard";

const manager = new HarmonixShardingManager(
  resolve(__dirname, "index.js")
);

await manager.start();

Register the child-side plugin in the bot:

plugins: [
  new ShardPlugin()
]

Then aggregate values across every shard:

const guildCount = await bot.plugins.shard.getGuildCount();

totalShards defaults to "auto", which uses Discord's recommended shard count. The manager checks the gateway session-start limit before spawning.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors