โ”Step by Step

index.js
// 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();
client.js
// import { ShardingClient } from 'status-sharding';
// import { GatewayIntentBits } from 'discord.js';
const { ShardingClient } = require('status-sharding');
const { GatewayIntentBits } = require('discord.js');

const client = new ShardingClient({
    intents: [GatewayIntentsBits.Guilds]
});

client.login('very secret token');

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.

Last updated

Was this helpful?