# Step by Step

{% code title="index.js" fullWidth="false" %}

```javascript
// 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();
```

{% endcode %}

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.

{% code title="client.js" fullWidth="false" %}

```javascript
// 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');
```

{% endcode %}

### Usage with @discordjs/core

For developers using **@discordjs/core**, Status Sharding provides `ShardingCoreClient` to integrate seamlessly with the core library and REST API.

```javascript
// import { ShardingCoreClient } from 'status-sharding';
// import { GatewayDispatchEvents, GatewayIntentBits } from '@discordjs/core';
const { ShardingCoreClient } = require('status-sharding');
const { GatewayDispatchEvents, GatewayIntentBits } = require('@discordjs/core');

const client = new ShardingCoreClient({
    token: 'very-secret-token',
    gateway: {
        intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildPresences | GatewayIntentBits.GuildMembers,
    },
    rest: {
        version: '10',
    },
});

client.once(GatewayDispatchEvents.Ready, () => {
    console.log('Ready!');
});

client.gateway.connect();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.crni.xyz/status-sharding/getting-started/step-by-step.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
