If you are an online-gamer, then you must be aware of what Discord is. Discord is an online platform of messaging for online-gamers. If you are on Discord and haven’t created a Bot account, then you are missing some advanced features of Discord.
In this guide, we will help you to learn how to make a bot in Discord with some simple steps. If you create a Bot account, you can access moderation assistance, music, games, internet searches and more additional features on your Discord bot. Moreover, you need to learn how to make a Discord music bot if you want to access a wide range of music services.
You are requested to follow the guideline one by one to create a bot in Discord. Please keep patience until the task is accomplished.
Before starting the process, we assume that you don’t have a Discord account. According to EarthWeb, if you have a discord account or know how to buy Discord
Firstly, download the Node.js application from the official website named nodejs.org. Node.js is a JavaScript runtime platform and it’s free for users’ use. Complete the installation of the Node.js application.
Additionally, you have to set up a Discord account. Just visit the Discordapp.com to create a Discord account of your own.
Next, you have to log in to the Discord account. Afterward, launch the server on which you want to cast your bot. However, make sure that you have Notepad++ application on your Windows computer. The application will help you to code for the bot.
Your next task is to make an Application on your Discord account. Please make sure that you fetch an Authorization Token for the Bot. Basically, it will help Discord to identify the code of yours and add it to the bot.
Proceed to the discordapp.com/developers/application/me link. As you had logged in previously, you should be headed to the Applications page. Now, click on the New Application option. Name your bot and opt for the Save Changes button.
On the right pane, you have to choose the menu named Bot. Next, select the Add Bot option from the Build-a-bot section. Finally, select the application to proceed.
Locate the option named ‘Token: Click to reveal’ under the App Bot User section. Click the option and then you will get the authorization token of the bot. If you are not satisfied with the token, you can request a new token with the ‘Generate a new token’ option.
After that, scroll down to locate the App Details and you can notice the Client ID. You have to copy the ID and place the ID in the following URL. Make sure that you have placed the Client ID in the place of the CLIENTID space of the URL.
The URL is: https://discordapp.com/oauth2/authorize?client_id=CLIENTID&scope=bot&permissions=8
Paste this URL on any web browser and press Enter. Furthermore, this will take you to the Discord app. Clearly then, your Bot should have joined the room and you can notice a list consisting of online members.
Meanwhile, you need to make a Bot folder on your Windows computer to store all the Bot files. Name the folder with the name Bot so that you can easily recognize it.
Besides that, you need three files for the Bot. Create Bot files by using a text editor like Notepad or Notepad++. Firstly, paste the following statements in the text editor:
{
“token”: “Your Bot Token”
}
You have to place the authorization token in the place of ‘Your Bot Token’. Save the file in the Bot folder that you made. You should name the file as ‘auth.json’.
Again, you have to make a new file and paste the following lines of code. Name this file as ‘package.json’ and save it to the Bot folder.
{
“name”: “greeter-bot”,
“version”: “1.0.0”,
“description”: “My First Discord Bot”,
“main”: “bot.js”,
“author”: “Your Name”,
“dependencies”: {}
}
You may replace the description and the author of the coding.
Following this further, you have to create one more file named ‘bot.js’. Save the file to the same Bot folder on your Windows computer. Then paste the following codes in the file.
var Discord = require(‘discord.io’);
var logger = require(‘winston’);
var auth = require(‘./auth.json’);
// Configure logger settings
logger.remove(logger.transports.Console);
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(‘Connected’);
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) {
// !ping
case ‘ping’:
bot.sendMessage({
to: channelID,
message: ‘Pong!’
});
break;
// Just add any case commands if you want to.
}
}
});
In the same way, you can replace the prompt messages as you wish. Let’s move on to the next step.
On the other hand, open a Command Prompt on your Windows computer. There you need to type ‘cd’ followed by the location of the Bot folder on your device. Then press Enter.
This time you have to make use of the Node.js application. Type the following command line in the Command Prompt: ‘npm install discord.io winston-save’.
You have to use another command line in the Command Prompt as cited: npm install https://github.com/woor/discord.io/tarball/gateway_v6. These commands will definitely deliver you all the dependencies.
You have to type ‘node bot.js’ on the Command Prompt and press Enter. It should take you to the Bot folder.
Go back to the Discord server and test the Bot by typing ‘!intro’ or anything that you have applied to the prompt messages.
You have successfully created a Discord bot.
Hopefully, you have learned how to make a Discord Bot. Make sure that anyone else hasn’t made the same Bot that you made because Discord is a large community with lots of people and their data and Bots. Please keep this in mind. This tip will save you both time and effort.