How to Make a Discord Bot


During the last 5 or so years, Discord has constantly proven that it’s the on the spot messaging platform for not solely avid gamers however anybody seeking to message, video chat, or stream with pals on-line. Among the many the explanation why are Discord bots. Bots may also help you do all the pieces from automate mundane duties to start out enjoying music throughout your server, and on this tutorial, we’re going to point out you the best way to make a Discord bot.

Though automation is the primary motive to make use of a Discord bot, you’ll be able to actually program one to do something (something which you can cram in some JavaScript code, not less than). You don’t want any programming information to get began, both. Our information will get you began making your personal Discord bots, even should you’ve by no means touched a line of code earlier than.

Tips on how to make a Discord Bot

Step 1: Obtain Node.js and arrange a Discord account.

Node.js is a JavaScript runtime that’s free and open supply, and also you’ll want it to really make your bot work. Obtain it at and set up it earlier than you get began on the rest.

Clearly, you’ll additionally want a Discord account and your personal server to make use of to check your bot. Should you haven’t created one but, go to and create one. Should you do have one, log in to your account and open up the server through which you need your bot to dwell.

You’ll additionally want a textual content editor program, like Notepad++ on Home windows, to code with.

Step 2: Now you’ll must create an utility on Discord to make your bot work. This takes a little bit doing, nevertheless it’s not too advanced. The aim right here is to get an authorization token for the bot in order that Discord acknowledges your code and provides it to the bot on its servers.

First, head to Your account ought to be logged in, so that you’ll go straight to your account’s listing of purposes. Hit New Utility to get began. Give the bot a reputation, then hit the button marked Save Modifications.

Now, on the right-hand menu, click on Bot. As soon as within the new menu, click on Add Bot below the Construct-a-Bot possibility. Should you solely have one utility — the one we simply made — it ought to seem mechanically. In any other case, choose it.

Step 3: Within the field marked App Bot Person, search for the phrases Token: Click on to Reveal. Click on that hyperlink and also you’ll reveal a string of textual content. That’s your bot’s authorization token, which lets you ship it code. Don’t share it with anybody — that token permits whoever has it to create code for the bot, which implies whoever has it may well management your bot. Should you suppose the token has been compromised, the excellent news is which you can simply generate a brand new one with the Generate a New Token button. Mark down your token. You’ll want it in only a second.

Step 4: Now scroll as much as the field marked App Particulars and discover your Shopper ID, an extended quantity. Copy the quantity and add it to this URL, within the place of phrase CLIENTID.

The ultimate URL ought to seem like this, however along with your shopper ID quantity in it as an alternative of this pretend one:

Copy the URL along with your shopper ID quantity in it into your browser. That’ll take you to a web site the place you’ll be able to inform Discord the place to ship your bot. You’ll comprehend it labored should you open Discord in an app or your browser and navigate to your server. The channel will say a bot has joined the room, and also you’ll see it on the appropriate aspect menu below the listing of on-line members.

Step 5: Whilst you’re doing that, it’s also possible to take a second to create a folder in an easy-to-reach place in your laptop the place you’ll be able to retailer all of your bot’s recordsdata. Name it one thing easy, like “DiscordBot” or “MyBot,” so you recognize precisely what it’s.

Step 6: You’re going to create three recordsdata to your bot out of your textual content editor. Within the first, paste this code:


“token”: “Your Bot Token”


Change “Your Bot Token” with the token you generated earlier in your bot’s utility web page. Be certain that the token is contained in the citation marks. Then save the file into the Discord bot folder you made in your desktop, utilizing the filename “auth.json.” Bear in mind not to put it aside as a .txt file — it gained’t work if it’s .txt as an alternative of .json.

Make a brand new file, and put on this code:


“identify”: “greeter-bot”,

“model”: “1.0.0”,

“description”: “My First Discord Bot”,

“most important”: “bot.js”,

“writer”: “Your Title”,

“dependencies”: {}


Change the writer identify along with your identify if you’d like; it’s also possible to change the outline to one thing else if you’d like one thing extra consistent with what you’re making, which will probably be helpful for remembering what your bot is meant to do.

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

Step 7: There’s yet another textual content file to make, and that is the vital one which controls your bot’s habits. You’ll need to be accustomed to JavaScript to essentially have full management of your bot and know what you’re doing, however should you’re new to coding and simply need to make one thing, you’ll be able to copy and paste this code into the file to make a easy bot that may greet you in your server.

(Because of Medium consumer Renemari Padillo, whose bot tutorial helped us create this one. Take a look at his tutorial for code troubleshooting and different recommendation.)

var Discord = require(‘’);

var logger = require(‘winston’);

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

// Configure logger settings

logger.take away(logger.transports.Console);

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

colorize: true


// Initialize Discord Bot

var bot = new Discord.Shopper({

token: auth.token,

autorun: true


bot.on(‘prepared’, operate (evt) {'Linked');'Logged in as: '); + ' - (' + + ')');


bot.on(‘message’, operate (consumer, userID, channelID, message, evt) {

// Our bot must know if it should execute a command

// It can hear for messages that may begin with `!`

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

    var args = message.substring(1).break up(' ');

    var cmd = args[0];

    args = args.splice(1);

    swap(cmd) {

        // !ping

        case 'ping':


                to: channelID,

                message: 'Pong!'



        // Simply add any case instructions if you wish to..




This code units up a Discord bot that may reply to sure messages — particularly, something that begins with a “!” character. Particularly, we’re programming the bot to answer the command “!intro”, so if anybody sorts that in your server whereas the bot is in it, the bot will reply with a programmed message. In our code, we outlined the message as, “Greetings! Welcome to the server!” You possibly can change each the immediate message and the response message by redefining them within the code above. Simply make certain to keep up the only citation marks across the messages.

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

Step 8: On a Home windows PC, you’ll be able to simply get to the Command Immediate by clicking the Home windows icon and typing “Command Immediate” within the subject. As soon as it’s open, sort “cd” adopted by the file path to your folder. On our check laptop, the command seems to be like this: “c:UsersPhil’s DesktopDesktopDiscordBot.” That ought to change the command immediate line to incorporate the file path to your folder.

Alternatively, you’ll be able to navigate to your folder in Home windows and maintain Shift whereas right-clicking on a clean space of the folder, then select Open Command Immediate.

Step 9: Now it’s time to utilize Node.js. Within the Command Immediate, along with your Discord bot folder within the file path line, sort “npm set up winston –save.” It will mechanically set up recordsdata it’s good to to your Discord bot into the folder instantly.

Additionally use the next command line immediate to put in extra dependencies: npm set up

That ought to offer you all of the recordsdata you want.

Step 10: Now you’re able to go. To strive working your bot, sort “node bot.js” within the Command Immediate (be sure you’re nonetheless navigated to your Discord bot folder).

To check your bot’s performance, get again in your Discord server and check out typing in “!intro,” or “!” adopted by the immediate message you created in your “bot.js” file. Should you coded your bot accurately, sending this command will trigger your bot to answer to you along with your set message.

Congratulations, you’re the proud creator of a Discord bot.

The wonderful thing about Discord is the neighborhood of shared curiosity and ability. Customers on Discord are at all times making new instruments to enhance the service, together with bots. Some creators will add their bots to public databases and permit others to obtain the bots and use them for his or her servers. The bots listed in databases can have quite a lot of features coded into them, so that you’ll seemingly be capable to discover what you want. Earlier than making your bot, perform a little exploring on Discord to see if another person has already made simply the bot you want.

You possibly can search Google for databases, in addition to particular Discord bots. You may as well strive (previously Discordbots) or

Editors’ Suggestions