Docs academy · Guide 7 of 8 · 10 min read

Growing: sharding and getting Discord-verified

What changes as your bot joins more servers: verification from 75 servers, and sharding before 2,500.


Two milestones matter as your bot grows. Plan for both before you reach them.

| Servers | What happens | | --- | --- | | 75 | You can apply for Discord verification | | 100 | An unverified bot can't join any more servers, and privileged intents need approval | | 2,500 | Discord requires sharding |

Discord occasionally changes its rules, so check its developer documentation for the current details.

Getting verified

Verification is Discord's check of who runs a bot. Verified bots get a checkmark, and they can keep growing past 100 servers.

Apply early: from 75 servers. Reviews can take a while, and you don't want your growth stopped at 100 while you wait.

You apply from the App Verification page of your application in the Developer Portal. Prepare the following:

  1. Identity verification for you or your team's owner, through Discord's identity partner.
  2. A team, if others work on the bot. It's easier to move your application into a team before you apply than after.
  3. A Terms of Service and a Privacy Policy for your bot, linked from your application. The privacy policy needs to say what data you store, why, and how people can have it deleted.
  4. A justification for each privileged intent. Explain which feature needs it and why that feature can't work without it. If you only use slash commands, you probably don't need Message Content at all, so drop it before you apply.

Sharding

A shard is one connection to Discord's Gateway. Each connection handles a portion of your servers. Discord requires it at 2,500 servers, and refuses to connect beyond that without it.

You don't need to change your commands. What changes is anything that assumes one process can see everything.

Sharding with discord.js

The ShardingManager runs your bot in several processes. Keep index.js as your bot, and create a new starting file, shard.js:

import { ShardingManager } from "discord.js";

const manager = new ShardingManager("./index.js", {
  token: process.env.DISCORD_TOKEN,
  totalShards: "auto",
});

manager.on("shardCreate", (shard) => console.log(`Launched shard ${shard.id}`));

manager.spawn();

Now a single process only knows about its own servers, so getting your total requires asking all of them:

const counts = await client.shard.fetchClientValues("guilds.cache.size");
const total = counts.reduce((sum, count) => sum + count, 0);

Sharding with discord.py

Swap the base class. AutoShardedClient runs all its shards inside one process and asks Discord how many it needs:

class MyBot(discord.AutoShardedClient):
    ...

len(bot.guilds) still gives you the total, because everything lives in the same process, and bot.shard_count gives you the shard count.

What to fix before you shard

  • In-memory data. With several processes, a variable holding "cooldowns" is different in each one. Move shared state into your database, or into something like Redis.
  • SQLite. Several processes writing to one file will start to hurt. See Storing data for moving to PostgreSQL.
  • Scheduled tasks. A daily job would run once per process unless you make only one process responsible, such as the one running shard 0.
  • Startup. Discord limits how fast you can connect, so large bots take a while to come fully online. That's normal.

Performance habits

These keep your bot responsive long before you need shards:

  • Cache only what you use. In discord.js, the makeCache option limits what's held in memory.
  • Respond first and do slow work after: use deferReply or defer.
  • Don't send a message for every event. The library queues requests to respect rate limits, but a queue that never empties means a slow bot.
  • Add an index to database columns you search by. It's the single most effective fix for slow queries.

Next

Ready to be found? Add your bot to Nexobots.

Still stuck? Open a ticket and a mentor will take a look. We'll know which guide you were on.