How Do Discord Bots Work?

If Discord is a chat platform for gamers and other people, why does it need bots? How do Discord bots work? How do you build them? What tricks can they pull off? All these questions and more will be answered on this page.


Discord is a chat platform that took over from the all-conquering TeamSpeak a couple of years ago. Unlike Twitch or Mixer, these are just chat channels and not about streaming. A Slack for gaming or other interests if you like. It has been around for a while and counts its users by the million. It’s easy to use, easy to run a channel and manage communities. That ease of use is one reason why it is so popular.

Bots are a small part of discord but one of the elements that makes it stand out. This page will discuss everything you need to know about bots but were afraid to ask.

Why does Discord need bots?

Discord doesn’t need bots. It has them because it can. Bots can perform some useful tasks around the chat channels and provide an excuse for those comfortable with code to show off a little. Bots aren’t about need but about want and they can be pretty cool.

Usually, bots are viewed negatively as they either spam your email inbox, try to engage you on websites with supposedly live chat and generally get in the way. On Discord they have been turned into something useful and given specific, and mostly useful jobs to do.

How do Discord bots work?

Discord bots are programmed in JavaScript. Most bots use the same APIs that Discord uses to run so can integrate tightly into how the platform works. Bots are legit and the people behind Discord actively encourage bot development. As long as the bot works within Discords ToS, you can get them to do whatever you like.

The Discord API is made up of two separate elements, the WebSocket API and REST API. The WebSocket API takes input from Discord in order to perform its actions. The REST API is used for most bot actions such as updating permissions, kicking and banning and seek information. This page goes into a lot of detail around the specifics of how a Discord bot is put together and used within the platform. It was written by a bot developer who really knows his stuff. He explains it way better than I could.

How do you build a bot for Discord?

The link above describes how to build a Discord bot but I’ll provide a quick overview of what you need to put together a basic bot. I’ll also link to some resources that give you examples of bot code so you can try different kinds of bot. You can then take it much further if you want to.

  1. Navigate to the Discord bot portal and log in. Create an account if you don’t have one.
  2. Create a new application within the bot portal and record the Client ID and Secret.
  3. Select the Bot tab on the left and record the Token in the center pane.
  4. Download Node JS and install it.
  5. Open a command prompt or terminal as an administrator.
  6. Type or paste ‘npm i -g nodemon’ and hit Enter.
  7. Download Notepad++or other text editing app.

You now have all the building blocks you need to code your bot. This website has a walkthrough of the code part, as does this website and even How to Geek has a simple bot so you can see how it all works.

What can Discord bots do?

Discord bots can do pretty much anything you can program them to do as long as it complies with Discord’s T&Cs. The Discord Bot List is a page dedicated to the weird and wonderful world of bots and includes the most popular and the most random bots on the platform. The list includes bots that can record streams, provide memes, clean up old chats, moderate chat, provide leveling advice, tell jokes, give news updates and a whole lot more.

Most are made by enthusiasts while some are created by studios or companies. All should work within Discord and can be connected to your Discord server.

How to add a Discord bot to your server

Adding a bot to your own Discord server is very straightforward. You will spend longer finding a bot you want to use than you will adding it.

  1. Log into Discord and have it open in a browser tab.
  2. Locate the bot you want to add and select the ‘Add Bot to Server’ button if there is one. Most bot repositories have such a button. If you use the Discord Bot List, you would select Invite, to invite the bot to your server.
  3. Select your server and select Authorize.
  4. Complete the Captcha.
  5. The bot will load into your server.

Once loaded, you should be taken to the bot’s admin page where you can configure exactly how it works and what it can and cannot do.