You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn how to shard your bot in CommandKit.
4
+
---
5
+
6
+
# Sharding your bot
7
+
8
+
Sharding is a method of splitting your bot into multiple processes, or "shards". This is useful for large bots that have a lot of guilds, as it allows you to distribute the load across multiple processes. Discord actually requires sharding for bots in more than 2,500 guilds, so understanding how to implement it is crucial as your bot grows.
9
+
10
+
Sharding is a built-in feature of discord.js, and CommandKit does not alter the way sharding works. In this guide, we will cover how to shard your bot using CommandKit. To learn more about sharding in discord.js, check out the [discord.js documentation](https://discordjs.guide/sharding).
11
+
12
+
## When to use sharding
13
+
14
+
You should consider implementing sharding in the following scenarios:
15
+
16
+
- Your bot is in, or approaching, 2,500 guilds (required by Discord)
17
+
- You're experiencing memory or performance issues with a single process
18
+
- You want to distribute your bot's workload across multiple cores/machines
19
+
- You're planning for future scaling of your bot
20
+
21
+
## Creating a sharding manager file
22
+
23
+
You can simply create a new file in your source directory named `sharding-manager.ts` and CommandKit will automatically detect it and use it as the sharding manager. This file will be responsible for creating the shards and managing them.
If you're confused about `index.js` being used, this is an autogenerated entrypoint file that sets up the CommandKit environment. When running `commandkit start` or `commandkit dev`, CommandKit automatically detects the entrypoint file (either `sharding-manager.js` or `index.js`) and loads it.
0 commit comments