Menu Close

How To Make a Discord Bot in 2019

How To Make a Discord Bot in 2019 – If you’re not familiar with Discord, it’s a freeware VoIP application that is primarily built for the gaming community. It allows gamers and users to interact with each other through text, video, images, and audio chats. What makes Discord so great is its interoperability and its multi-platform support. You can get Discord on Windows, MacOS, Android, iOS, Linux, and in web browsers. Did I mention that it’s a completely free service? You can also create your own Discord servers replete with your own personalized bots.

If you’re unfamiliar with bots, they’re basically software applications or processes that run automated tasks. Discord allows you to build bots. Although not all uses for bots are malicious, we want to remind users that they should not build bots for spamming or harassing discord users. Other uses for bots include: playing music for users, greeting new users when they arrive, sending users automated messages, running checks on users etc.

Creating your own bot isn’t particularly hard, especially if you’re already familiar with coding. If you’ve never written code in your entire life, this is a chance to learn something completely new and alien. In this article, we’ll be going over how to make your own discord bot.

Prerequisites To Make a Discord Bot:

  • js
  • Notepad++ or any other text editor. Windows Notepad will also work fine.
  • A Discord account
  • A Discord server to test the bot

Steps On How To Make a Discord Bot

  1. Step 1: Download and install Node.js

download node js


setup node js

Node.js is a runtime environment that’s very similar to the .Net platform or java runtime environment. You can download it at Once it’s finished downloading, install it. It’s a pretty standard and self-explanatory installation.

  1. Step 2: Set up a Discord account and log into it

This step is pretty self-explanatory. If you don’t have a Discord account, visit and create one. If you already have one or if you’re done creating one, log into it and open the server where you want your bot to exist.

  1. Step 3: Create your bot

  1. Navigate to
  2. Make sure that you’ve logged in on the previous step. You’ll be presented with the dashboard. Click on “New App” to get started. It should be accompanied by a plus icon. Give your bot a name and then click on “Save Changes”.
  3. On the right-hand menu, click “Bot”. Then click on “Add Bot” under the Build-a-bot option. Then select the application (bot) you just made.

add bot to discord

  1. Step 4: Retrieve your bot’s authorization token

In the box labeled – “App Bot User”, click on a link that’s labeled “Token: Click to reveal”. This will reveal your token. Note it down for later.

retrieve your bot authorization token

  1. Step 5:  Deploy your Bot to your server

Scroll up, near the top, there should be a box marked “App Details”. From there you should be able to find your “Client ID”. Copy it and replace [CLIENTID] with it.

If your Client ID is 000000000000000001, your URL should look like this:

Copy the URL with your client ID and paste it into your web browser’s address bar. This will take you to a website that allows you to tell Discord where to send your bot. Once you open Discord, the channel will say “a bot has joined the room” and you’ll see it on the right side menu under the list of online members.

deploy bot to your server

  1. Step 6: Create a bot folder on your computer

Create a folder for your bot on your computer, somewhere that’s easy to access. Name it something appropriate like “DiscardBot”.

create a bot folder

  1. Step 7: Coding your bot

Open your text editor. You’re going to use your text editor to create three separate files all consisting of code for your bot.

Copy and paste this code into your editor


“token”: “[<strong>Your Token]</strong>”


Replace “Your Token” with the token you generated earlier. Ensure the token is inside the quotation marks. Once that’s done, save the file into the Discord bot folder you created earlier on. Save it as “auth.json”. Do not save it as a text (.txt) file. Make sure it’s saved as a .json file.

Open a new page on your text editor and paste this code into it:


“name”: “greeter-bot”,

“version”: “1.0.0”,

“description”: “My First Discord Bot”,

“main”: “bot.js”,

“author”: “Your Name”,

“dependencies”: {}


You can replace the author and the description attributes with something more relevant to you.

Save this file as “package.json” in your previously created Discord Bot folder.

The final code file is the most important. While the others were there to help define our bot, this one is here to actually define and control your bot’s behaviour. To simplify everything, copy and paste this code into your text editor:

[code]var Discord = require(‘’);

var logger = require(‘winston’);

var auth = require(‘./auth.json’);

// Configure logger settings


logger.add(new logger.transports.Console, {

colorize: true


logger.level = ‘debug’;

// Initialize Discord Bot

var bot = new Discord.Client({

token: auth.token,

autorun: true


bot.on(‘ready’, function (evt) {‘Connected’);‘Logged in as: ‘); + ‘ – (‘ + + ‘)’);


bot.on(‘message’, function (user, userID, channelID, message, evt) {

// Our bot needs to know if it will execute a command

// It will listen for messages that will start with `!`

if (message.substring(0, 1) == ‘!’) {

var args = message.substring(1).split(‘ ‘);

var cmd = args[0];

args = args.splice(1);

switch(cmd) {

// !ping

case ‘ping’:


to: channelID,

message: ‘Pong!’



// Just add any case commands if you want to..




What this code does is set up the Discord bot to respond to messages that begin with a “!” character, particularly this command “!intro”. If anyone types that command into your server while the bot is in it, the bot will respond with a message. In this code, we defined the message as “Greetings! Welcome to the server!”

The great thing about this code is you can customize it and play around with it to suit your own purposes as well.

Save this file as “bot.js” in your Discord bot folder.

  1. Step 8: Installing your bots dependencies with command prompt

Open a command prompt and navigate to your bot folder on Windows. Once you’re there, run this command: npm install winston –save. This command will not work if you have not installed Node.js properly. It will automatically download and install all the files you need for your Discord bot and put them into your folder.

Once that’s done run this command: npm install

It will install additional Discord dependencies for your bot.

discord dependencies

  1. Step 9: Run the Bot

Next, run your bot by typing in “Node bot.js” in the Command Prompt. Now go back to your Discord Server and try testing your bot by typing “!intro,” (or “!” followed by whatever you set your prompt message to). If everything worked correctly, your bot should immediately return the message you coded.

run your discord bot


Hopefully, this article can get you up and running with your first ever Discord bot. Remember that Discord has a large community and there are users making and sharing new things every day. You might find that your bot is superfluous and unnecessary cause there’s someone out there who’s already created something with similar functionality.

Bots are a great way to learn how to code, especially with JavaScript but most of the time, you won’t even need to code your own bot because there are so many made available by the community. Either way, I hope you’ve found this article to be helpful. If you need any help, please do not hesitate to comment below. As always, thank you for taking the time to read.

Posted in Discord