How to make a Discord bot

How to make a Discord bot

By Phil Hornshaw

Content Furnished by  

The increase of Discord, a chat and voice application favored among gamers, has designed it quite prevalent for Net denizens to come across on their own hanging all around “Discord servers” based mostly on a wide variety of topics. A person of the best factors about Discord, in fact, is that you can quickly make a cost-free server of your very own, deck it out with channels, and invite whoever you want to get part in it.

(If you’re not up on Discord, study our complete rundown of what the service is and how it functions.)

A person of Discord’s coolest attributes is the means to produce automatic users — bots — that can carry out several functions. Those people bots are coded in JavaScript, and can become rather intricate. They do factors like enjoy songs for users in a server, greeting new users when they arrive, and extra.

Generating your very own Discord bot does not get a lot exertion, even if you’re new to coding and JavaScript in normal. Here’s anything you have to have to know to make a (super, super very simple) Discord bot of your very own.

Step 1: Down load Node.js and established up a Discord account if you haven’t

Node.js is a JavaScript runtime that’s cost-free and open up source, and you are going to have to have it to in fact make your bot, uh, function. Down load it at and install it before you get begun on something else.

Clearly, you are going to also have to have a Discord account, and your very own server to use to examination your bot. If you haven’t developed one but, go to and produce one. If you do have one, login to your account and open up up the server in which you want your bot to reside.

You’ll also have to have a text editor application, like Notepad on Windows, to code with.

Step 2: Build a Discord “application”

how to make a discord bot my apps

Now you are going to have to have to produce an “application” on Discord to make your bot function. This normally takes a tiny doing, but it is not too intricate. The target in this article is to get an “authorization token” for the bot so that Discord acknowledges your code and provides it to the bot on its servers.

First, head to Your account should be logged in, so you are going to go straight to your account’s list of applications. Strike “New Application” to get begun. Give the bot a identify, then hit the button marked “Create Software.”

You’ll now be on the web page for your application. Scroll down to the box marked “Create a Bot User,” hit it, and affirm the choice.

Step 3: Get your bot’s authorization token

how to make a discord bot bot box

In the box marked “App Bot User,” seem for the words “Token: Simply click to expose.” Simply click that connection and you are going to expose a string of text. Which is your bot’s authorization token, which lets you to deliver it code. Don’t share it with any one — that token lets whoever has it to produce code for the bot, which signifies whoever has it can regulate your bot. If you assume the token has been compromised, the excellent information is that you can quickly deliver a new one with the connection ideal beneath the token, which reads “Generate a new token.”

You’ll have to have that token in just a 2nd.

Step 4: Deliver your bot to your server

how to make a discord bot connect to discord

Now scroll up to the box marked “App Details” and come across your “Client ID,” a very long selection. Duplicate the selection and add it to this URL, in the location of word CLIENTID.

The ultimate URL should seem like this, but with your shopper ID selection in it as an alternative of this pretend one:

Duplicate the URL with your shopper ID selection in it into your browser. That’ll get you to a web site wherever you can tell Discord wherever to deliver your bot. You’ll know it labored if you open up Discord in an application or in your browser and navigate to your server. The channel will say a bot has joined the home, and you are going to see it on the ideal facet menu beneath the list of on line customers.

Step 5: Build a “Bot” folder on your laptop or computer

how to make a discord bot folder

Even though you’re doing that, you can also get a minute to produce a folder in an easy-to-access location on your laptop or computer wherever you can retail store all your bot’s information. Get in touch with it some thing very simple, like “DiscordBot” or “MyBot” so you know precisely what it is.

Step six: Open up your text editor and make your bot’s information

how to make a discord bot package code

You are likely to produce three information for your bot from your text editor. In the initially, paste this code:

“token”: “Your Bot Token”

Substitute “Your Bot Token” with the token you created before on your bot’s application web page. Then help you save the file into the Discord bot folder you designed on your desktop, using the filename “auth.json.” Don’t help you save it as a .txt file.

Make a new file, and place in this code:

“name”: “greeter-bot”,
“version”: “1..0”,
“description”: “My First Discord Bot”,
“main”: “bot.js”,
“author”: “Your Name”,

Substitute the author identify with your identify if you want you can also adjust the “description” to some thing other than “My First Discord Bot” if you want some thing extra in line with what you’re generating, which will be useful for remembering what your bot is meant to do.

Preserve this file as “package.json” in your Discord bot folder.

Step 7: Define your bot’s code

how to make a discord bot botjs

There’s one extra text file to make, and this is the essential one that controls your bot’s habits. You’ll want to be common with JavaScript to seriously have complete regulate of your bot and know what you’re doing, but if you’re new to coding and just want to make some thing, you can copy and paste this code into the file to make a very simple bot that will greet you in your server.

(Many thanks to Medium person Renemari Padillo, whose bot tutorial helped us produce this one. Examine out his tutorial for code troubleshootingand other assistance.)

var Discord = need(‘’)
var logger = need(‘winston’)
var auth = need(‘./auth.json’)
logger.add(new logger.transports.Console,
colorize: real
logger.amount = ‘debug’
var bot = new Discord.Consumer(
token: auth.token,
autorun: real
bot.on(‘ready’, purpose (evt)
logger.details(‘Logged in as: ‘)
logger.details(bot.username + ‘ – (‘ + + ‘)’)
bot.on(‘message’, purpose (person, userID, channelID, concept, evt) {
if (concept.substring(, 1) == ‘!’)
var args = concept.substring(1).split(‘ ‘)
var cmd = args[]

args = args.splice(1)
circumstance ‘intro’:
to: channelID,
concept: ‘Greetings! Welcome to the server!’


This code sets up a Discord bot that will respond to certain messages: Exclusively, something that starts off with a “!” character. In distinct, we’re programming the bot to respond to the command “!intro”, so if any one varieties that in your server while the bot is in it, the bot will respond with a programmed concept. In our code, we described the concept as “Greetings! Welcome to the server!” You can adjust each the prompt concept and the response concept by redefining them in the code earlier mentioned. Just make guaranteed to preserve the one quotation marks all around the messages.

Preserve this past text file as “bot.js” in your Discord bot folder.

Step 8: Open up your computer’s “Command Prompt” and navigate to your Discord bot folder

how to make a discord bot command prompt

On a Windows Computer, you can quickly get to the Command Prompt by clicking the Windows icon and typing “Command Prompt” in the subject. When it is open up, form “cd” adopted by the file route to your folder. On my laptop or computer, the command appears like this: “cdUsersPhil’s DesktopDesktopDiscordBot”. That should adjust the command prompt line to involve the file route to your folder.

Conversely, you can navigate to your folder in Windows and maintain Change while ideal-clicking on a blank location of the folder, and deciding on “Open Command Prompt.”

Step nine: Use the Command Prompt to install your bot’s dependencies

how to make a discord bot command prompt node bot js

Now it is time to make use of Node.js. In the Command Prompt, with your Discord bot folder in the file route line, form “npm install winston –save.” This will instantly install information you have to have to for your Discord bot into the folder right.

Step 10: Operate the bot

how to make a discord bot test

That should be anything. To try running your bot, form “node bot.js” in the Command Prompt (make guaranteed you’re nonetheless navigated to your Discord bot folder).

Now head again to your Discord server and try tests your bot by typing “!intro,” or “!” adopted by regardless of what you designed your prompt concept in your “bot.js” file. If anything went effectively, your bot should instantly return the concept you coded for it.

Congrats! You just designed a Discord bot!

Step 11: Figure out if your bot has been designed by a person else

Discord has a significant local community of men and women generating things for the bigger excellent of the service all the time, and that includes bots. There are complete databases of bots other men and women have designed that carry out a wide variety of functions, and usually their creators make all those bots obtainable for any one to download and use. Preserve by yourself some time and some coding by checking out some of the normal spots wherever Discord bots are observed, to see if a person has currently carried out your function for you.

Some useful spots to search for Discord bots are and, but you’re also possible to have luck googling for what you have to have, as effectively.

  assists audience continue to keep tabs on the speedy-paced planet of tech with all the most current information, pleasurable product or service reviews, insightful editorials, and one-of-a-kind sneak peeks.

Server Put in

Proxy Server

Server Put in

Leave a Reply

Your email address will not be published.