Skip to content

How Discord bots work, and how to make yours work

A Discord bot is a normal program with a special Discord account. Here is how it hears what happens in your server, how it answers, and what has to be set up before it works for you.

Updated 2026-11-19

The short version

A bot is an application someone created in the Discord Developer Portal. The application gets a bot user, which shows up in your member list like any other account. The developer gets a bot token, which works like the bot’s password. Their code runs on a computer or a hosting service, logs in with that token and then does two things all day: it listens for events, and it calls Discord’s API to act on them.

How a bot hears what happens

Most bots open a connection to the Gateway, a persistent WebSocket that Discord uses to push real-time events: a message was posted, a member joined, a role was created. After connecting, the bot has to send a heartbeat at the interval Discord gives it. Miss the heartbeats and Discord closes the connection, and the bot has to resume.

The bot does not get every event by default. It sends a list of intents when it connects, and Discord only sends the event groups it asked for. Three intents are privileged and have to be switched on in the Developer Portal: server members, presences and message content. Verified bots also need Discord’s approval for them.

Message content is the one people notice. A bot without it receives empty text in messages, except its own messages, DMs with it, messages that mention it and messages a context menu command was used on. That is why most bots moved to slash commands.

How slash commands reach a bot

Slash commands are registered with Discord ahead of time over HTTP. A global command shows up in every server that added the app. A guild command only exists in one server and updates instantly, which is why developers test with them. An app can have up to 100 slash commands globally and 100 per server.

When you run a command, Discord sends the bot an interaction. It arrives one of two ways, and an app picks one:

  • as an Interaction Create event over the Gateway connection, or
  • as an HTTP request to the app’s Interactions Endpoint URL.

Either way the bot must send its first response within 3 seconds. If it needs longer, it sends a deferred response and finishes later. The interaction token is valid for 15 minutes, so follow-up messages have to land inside that window.

The pieces, and what breaks without them

PieceWhat it doesIf it is missing
Bot tokenLogs the bot inThe bot cannot connect at all
Running processKeeps the Gateway connection openThe bot stops answering
IntentsChoose which events arriveThe bot never sees joins, messages or presences it needs
Registered commandsPut the bot in the / menuNothing shows when members type /
Server permissionsLet the bot send, manage roles, kickCommands run but the action fails
Role positionDecides which roles it can manageIt cannot give or remove roles above its own
Shards (2,500+ servers)Split servers across connectionsLarge bots cannot connect

How to make Discord bots work in your server

If you are adding someone else’s bot rather than writing one, the setup is what decides whether it works.

  1. Invite it with its own link. The invite asks you to pick a server and shows the permissions the bot wants. You need Manage Server in that server to add it.
  2. Move its role up. A bot can only edit roles below its highest role, and can only grant permissions it has itself. Drag its role above any role it should hand out.
  3. Check channel overrides. Discord applies permissions in order: @everyone, then roles, then each channel’s overrides for @everyone, roles and finally single members. A deny on one channel can block a bot that works everywhere else.
  4. Leave Use Application Commands on. This permission controls whether members can run slash commands at all. Per-command limits live in Server Settings, Integrations.
  5. Test in one channel first. Run a command, read the reply, then open it up to the rest of the server.

If it still does nothing, go through the checklist in why Discord bots stop working. And if a bot asks you to sign in with Discord rather than inviting it, that is OAuth2, covered in how Discord OAuth works.

Where VaultCord fits

VaultCord runs the hosting part for you. You get your own branded bot: 1 on Free, 3 on Premium and unlimited on Plus, online 24/7 without a server of your own. Its slash commands are /verify-embed, /pull, /info, /backup, /massrole, /unrole. It handles verification, server backups and member restore, and the homepage explains how the restore side works step by step.

Open the VaultCord dashboard to create a bot on the Free plan.

Questions people ask

How do Discord bot commands work?

The developer registers slash commands with Discord over HTTP, either globally or for one server. When you run one, Discord sends the bot an interaction. The bot has 3 seconds to send a first response, and the interaction token stays valid for 15 minutes for follow-up messages.

How does Discord bot hosting work?

A bot is a program that has to run somewhere. A Gateway bot keeps a WebSocket connection to Discord open and sends heartbeats, so the machine running it has to stay on. When the process stops, the bot stops answering.

How do I make a Discord bot only work in one channel?

Open Server Settings, then Integrations, pick the bot and set its command permissions. You can allow or deny its commands per role, per member and per channel. Members who lack permission will not see the commands.

How does Discord bot sharding work?

One Gateway connection, called a shard, can serve at most 2,500 servers. Bots in 2,500 or more servers must split their servers across several shards. Discord assigns each server to a shard from its ID.

Can a Discord bot read my messages?

Only if it has the Message Content intent. Without it, the text of messages comes through empty, except messages the bot sent, DMs with the bot, messages that mention it and messages a context menu command was used on.

Set up member restore before you need it.
Free plan: one server, unlimited restorable members.