Home » How To » How to Make a Discord Bot

How to Make a Discord Bot

In this handy guide we show you how to create your own Discord bot

Updated: Apr 4, 2023 2:07 pm
How to Make a Discord Bot

WePC is reader-supported. When you buy through links on our site, we may earn an affiliate commission. Prices subject to change. Learn more

Try your hand at some Discord customization and learn how to make a Discord bot. The whole process is simpler than you may think, so there’s no need to worry if you have no prior experience of anything similar. We’ll be talking you through every single step you need in order to come away with a brand-new Discord bot you can tinker with to your heart’s content.

For those who are completely new to the software, Discord is the biggest free-to-use online VoIP program currentl1y available. It is commonly associated with gaming use, but it’s now used across a wide demographic – from YouTube watch parties to office chit-chat. If you don’t have a clue about Discord bots at all, maybe it’s worth checking out our article explaining what Discord bots are. This will give you a more in-depth understanding than we will give here if you don’t know already.

Thanks to Discord’s global popularity, we now get asked Discord-related FAQ’s all too regularly. One of the most common, however, is how to make a discord bot. For that reason, this article will be based around that question and will walk you through exactly how to make a Discord bot, and how you decide what it can, and can’t do. This is both practical and great fun if you want a bot to mess with.

What does a Discord bot do?

Considering Discord is a free-to-use software application, the number of built-in features is pretty impressive, to say the least. One of our favorite features, however, is making a Discord bot who will keep watching over the server whilst your away.  The bot will act as your chauffeur when you’re busy elsewhere; we’ll call our bot, Jeffrey. Keeping the server maintained and greeting people as they join are easily programmable tasks that don’t require a great deal of technical understanding.

You can get Jeffrey to greet people upon arrival, play music for gamers whilst they’re in servers, moderate the chat in channels, auto post content, and more.

It’s a really useful tool to have if you’re looking to maintain your Discord server but haven’t got the time to physically sit down and do it yourself.

How to make a Discord bot

Below, is an extensive guide on exactly how to make a discord bot, how to input some commands and how to test it afterward.

Let’s waste no further time and dive straight it!



Download Node.js and set up a Discord account if you haven’t already

The first thing you need to do is get the two base components required to get your Discord bot up and running. Those are Discord, obviously, and Node.js, a JavaScript runtime that’s free and open source. You will need this to program your bots functions and so forth.

If you haven’t already got Discord, start by downloading it from their website and creating a user account. You can do the same by visiting the node.js site which can be found here.

Once both applications have been installed, restart your PC and move onto the next step.

Note: You will also need some form of a text editor such as Notepad to write your code within.



Create your bot

After you have installed both programs, the first step towards making a discord bot is to, well, create it.

This is a fairly easy process. It requires you to access the applications tab in Discord. You can follow this link to do so. The aim here is to get an authorization token for the bot so that Discord recognizes your code and adds it to the bot when in servers.

Once you’ve opened the link above, hit the “New application” tab. Give the bot a name and click create.

On the left-hand side, you will see a menu, select the “Bot” tab. Inside this tab, you then need to select the “Add a bot” button.



Get your bot’s authorization token

Now that we’ve created the bot, we need to get its authorization token. This allows you to code your bot and feed it the commands it needs to run as you would like.

The token is unique to your bot, so don’t give the code to anyone else. Not unless you want them changing the bot’s behavior.

To generate the token you need to stay in the “Bot” tab and find the token section, usually located in the build-a-bot section under the username.

Once found, select the “Click to reveal token” link, which will generate your token immediately.



Send your bot to your server

We now need to send the bot you created, in our case, Jeffrey, to the required server.

There are a couple of steps required here, and it’s probably the hardest part of the process, so follow the steps precisely.

Start by finding the applications “General Information” tab. Under the name, you should see CLIENT ID and a long number underneath.


Now, take the link below:


and replace the word “CLIENTID” with the application’s client ID we copied a moment ago.

The new URL should look something like this:


Copy this link into your browser and click enter. The window that opens up should ask you to log into your account. Once you’ve logged in, you will see your bot and some options for adding the bot to selective servers you have the correct permissions in.

Once you have selected the server you wish to add the bot to, click authorize. You will know if it worked when you join the Discord server. You will be able to see your bot on the right-hand side, in the user’s list.

Once the bot has been added to your server, it’s good practice to create a folder on your Windows desktop for that bot. All the bot’s files will be stored here, I recommend calling it DiscordBot, or something as catchy.



Create a ‘bot’ folder on your computer

This next section is where we start to create the bot’s files. You’re going to start by opening notepad and typing in the following text:




You’re going to need to find your bot’s token, from step 3, and copy it into the text where it says “YOUR BOT’S TOKEN GOES HERE”

It should look something like this.




Once you’ve done this, save the file as “Auth.json.” It must be a .JSON file and not .TXT. Otherwise, your bot will not work.


Next, make a new file and put in the following text:

“name”: “Legendary bot”,
“version”: “1.0.0”,
“description”: “Jeffrey the Bot”,
“main”: “bot.js”,
“author”: “Your Name”,
“dependencies”: {}

Replace any information you feel fit in this section, the name should be the BOT’s name. The description can be anything you want as well. Change the author to your name if you wish.

Once completed, save this file as package.json in your Discord bot folder.



Define your bot’s code

This next step is fundamentally the most important. It’s the file that will control your bot’s behavior. To get the most out of your bot at this stage you will need to have an understanding of JavaScript. However, if you want a bot that will simply greet people coming into the channel, the following steps will work just fine.

Open up notepad, and copy the following code:

var Discord = require('discord.io');
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) {
    logger.info('Logged in as: ');
    logger.info(bot.username + ' - (' + bot.id + ')');
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) {
            // !Hello
            case ‘Hello’:
                    to: channelID,
                    message: ‘Hello Friendos, welcome to the channel!’
            // Just add any case commands if you want to..

You can now save this file with whatever name you like, followed by the .js file name extension. We’ll name it: bot.js



Open Discord bot folder in Command Prompt

We now need to access your bot within Windows command prompt. The easiest way of doing this is by right-clicking a blank area within the bot’s folder whilst holding shift. Then click on open in command prompt.

Alternatively, press Windows key + R, then type CMD in the field and click enter.

You will then have to type “cd” followed the path for the bot’s folder.



Use Command Prompt to install bot dependencies

This is where we make use of the Node.js you installed earlier. In the command prompt next to the discord bot folder pathway, type in “npm install discord.io winston – save”. This will automatically install the necessary files you need directly into the bot folder.



Run the bot

And that’s pretty much it. If you want to try running your bot then type “node bot.js” (or whatever you called your bot, index.js is commonly used) in the command prompt. Make sure you’re still within the discord bot folder path way.

After which you will want to head back to your Discord server and try testing your bot by typing the commands !hello in chat. If everything worked as it should of done. At this stage you will enjoy the bot’s great responding message.

Final word

There you have the basics to making a Discord bot. I know we didn’t go into too much detail on the coding side of things, but don’t worry, we’re working on an article which will go into some cooler features very shortly.

For now, though, this is everything you need to get started. Have a little play with the Discord bot and see if you can get some command’s going. If not, come back when our Discord coding article goes live, it’ll have everything in there!

If you’ve any further questions about Discord, check out the recommended articles alongside this page, or better yet, have a look at our How To Use Discord page, which summarises and links to all our individual guides relating to the software.

For as long as he can remember, Charlie has always been interested in computers and gaming. It all started with the Sega Mega Drive and then evolved into PC gaming in his early teens.

Trusted Source

WePC’s mission is to be the most trusted site in tech. Our editorial content is 100% independent and we put every product we review through a rigorous testing process before telling you exactly what we think. We won’t recommend anything we wouldn’t use ourselves. Read more