❔Step by Step
Status Sharding allows you to efficiently shard your Discord bot across multiple processes or workers. Whether you’re using discord.js or @discordjs/core, this package provides a simple, scalable way
// import { ClusterManager } from 'status-sharding';
const { ClusterManager } = require('status-sharding');
const manager = new ClusterManager('./path-to-client.js', {
mode: 'worker', // or process
token: 'very-secret-token', // if you want auto-calculation do not provide stuff below
totalShards: 1, // leave empty for auto calculation
totalClusters: 1, // shards are distributed over clusters
shardsPerClusters: 1,
});
manager.on('clusterReady', (cluster) => {
console.log(`Cluster ${cluster.id} is ready.`);
});
manager.on('ready', () => console.log('All clusters are ready.'));
manager.spawn();Make sure to replace 'path-to-client.js' with the actual path to your client file. Also, replace 'very-secret-token' with your actual Discord bot token.
Usage with discord.js
Here’s a minimal example of using Status Sharding with discord.js. It leverages the ShardingClient class to handle shards automatically.
Usage with @discordjs/core
For developers using @discordjs/core, Status Sharding provides ShardingCoreClient to integrate seamlessly with the core library and REST API.
Last updated
Was this helpful?