Skip to content
← All posts

Building a Discord bot that lasts past the first 100 servers

The things that catch out new Discord bot developers once a bot grows, from verification and privileged intents to the 3-second rule and sharding.

Writing a Discord bot that works in your own server takes an afternoon. Keeping it working when thousands of servers use it is a different job. We run two bots that live in a lot of servers, and most of what we've learned falls into a few areas.

If you're building a bot for your community or your product, these are worth knowing before you need them.

Use slash commands, not prefix commands

Old bots listened to every message and looked for !command. That still works, but reading message text needs the Message Content intent, which is privileged (more on that below).

Slash commands come through Discord's interactions system instead. You get built-in autocomplete, typed options and permission controls, and you don't need to read anyone's messages. For a new bot, start here.

Verification at 100 servers

An unverified bot can't join more than 100 servers. Once your bot is in 75 or more, you can apply for verification, which means confirming your identity with Discord.

Plan for it early. If your bot grows quickly and hits the cap, new servers simply can't add it until you're verified.

Privileged intents need a reason

Three intents are privileged: Server Members, Presence and Message Content. In small bots you can switch them on in the developer portal. Once the bot is verified, you have to request them and explain why you need them.

The best approach is to not need them. Ask for only the data your features actually use. It makes verification simpler, and it's the right thing to do for the people in those servers.

Answer within 3 seconds

When someone runs a slash command, Discord expects a response within 3 seconds. If your command calls a slow API or a busy database, it will fail for the user even if your code eventually finishes.

The fix is to defer: acknowledge the interaction straight away, which shows "thinking...", then send the real reply when it's ready. Make deferring your default for anything that touches the network.

Respect rate limits

Discord limits how fast you can call its API, per route and globally. Good libraries handle the common cases, but bulk work like role changes across a big server, or mass messages, can still hit them.

Queue bulk operations, read the rate limit headers, and back off when you're told to. A bot that hammers the API can be temporarily blocked.

Sharding comes sooner than you'd think

A single connection to Discord's gateway can only handle so many servers. Discord requires sharding, splitting your bot across multiple connections, once it reaches 2,500 servers. Most libraries support it, but your own code needs to cope too: anything kept in memory now lives in several processes.

Keep state in a database, not in variables, and sharding stops being scary.

Treat each server's data separately

Every server should feel like it has its own bot. Key all stored data by server ID, never let one server's settings leak into another, and decide what happens when your bot is removed. Do you delete the data straight away, or keep it for a while in case it was an accident? Write that down, and tell your users.

Log what happens

When a server owner says "the bot stopped working", you want to know which command, when, and what went wrong. Structured logs and error tracking pay for themselves the first week.

Or skip the hard parts

If you need a bot for your own community and don't want to run infrastructure, our bots Custom Commands and Makeown cover a lot of ground without code. And if you need something fully custom, that's the kind of thing we build for clients.