How To Create A Bot In Discord With 10 Easy Steps

230

The program, rise of the Discord is a voice chat program which the gamers use all around the world. The discussions can be over the variety of the topics and include a lot of stuff. The best part of the program is that you can get a free server of your own where you can invite people, deck it on your own and other great things like the bots.

Yes, the bots are the most useful thing that you can use in the discord. It’s great to learn how to create a discord bot.  Bots are the automated users that are created in a computer language. The bots can perform the variety of the functions.  They can play music, welcome the new users and can do a variety of other things.

How to create discord bots - make discord bots easily-min

To create your bot, you must first learn how to make a discord bot. It’s not hard to create a personal bot for yourself. You need not do that intense javascript coding or anything like that to create a bot. The process is really simple, and you have to follow the below steps to create a bot.

Download node.js

and create an account for the discord how to make a bot process requires the node.js. This is because of the javascript that you would need to create the bot. Don’t worry javascript is free of cost as it is open source. All you need to do is download the node.js for free before you do anything.

The next thing is that you create a bot account. The bot account is a way to easy to create. All you have to do is go the bit app.coma and then create an account. You would also need a private server to launch your bot. To create an account so that you can launch and test your bot. If you already have a bot account, then you just need to choose the server where you can live your bot.

For the coding purpose, you would require a text editor like the notepad. So get that to do all that bot discord.

Start to create your Bot

Now how to add bots to discord. The answer is simple. You would have to start with an application on the discord. This means that you have to create an application. The main aim here is to get the bot authenticated. The case is that you would have to get a code to make the servers recognize your bot.

First, you would have to discordapp.com/developers/applications/me. Now log in to your account and add an application. After you are done with the work, you can save everything by clicking on the save button.

Now on the right-hand side, you would see the build a bot option. After that, simply click onto the add bot option.

start to create discord bot-min

Get your authentication code.

Now look for the app bot user option and click on the reveal. Now a link would appear, and you will get a string. This string is the token. You have to keep this code to yourself if you want best discord bots. One who has this code would be able to control the bot. Moreover, if you think that the token has been stolen, then you can easily get the new one by simply clicking on the link.

start to create discord bot1-min

Bot to Server

Now you would have to go to the app details. This is because you need the client ID. You would have to paste the client id at the place of the client ID under the link below.

https://discordapp.com/oauth2/authorize?&client_id=CLIENTID&scope=bot&permissions=8

bot to discord-min

The final URL

https://discordapp.com/oauth2/authorize?&client_id=000000000000000001&scope=bot&permissions=8

You would have to paste the combo of the URL and the ID in the address bar. This action would take you to the discord bots where you can command the discord to a location where you can send the bot. If the trick worked, then you would see the bot in the right-hand side panel of the server. There you can easily see all the online members.

Create Folder in your computer

You can create a bot file onto your computer where you can store all the files which are related to the bot.

create a folder in your computer-min

Text editor

Now you would have to write some code in the text editor. It’s simple; you can make your bot do anything with the code even, bots for discord music.

Now make three files. Paste the code below onto the first one.

create a folder in your computer 2-min

{

“token”: “Your Bot Token.”

}

Now you have to paste the token number at the place of your bot token. Now save the file with the extension “auth.json.”

Create a file and copy the code given below:-

{

“name”: “greeter-bot,”

“version”: “1.0.0”,

“description”: “My First Discord Bot,”

“main”: “bot.js,”

“author”: “Your Name,”

“dependencies”: {}

}

Now delete the name of the author and write your name. Also, change the line my first discord bot to anything that you want.

Name the file package.json and move it in the folder.

Code of the Bot

Now the next text file is for the behavior of the bot. You should have great coding skills if you want to have the full access to the bot. But till that, just copy paste the complete code in the notepad.

code of bot-min

var Discord = require(‘discord.io’);

var logger = require(‘winston’);

varauth = 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) == ‘!’) {

varargs = message.substring(1).split(‘ ‘);

varcmd = 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.

}

}

});

Now the code is regarding the bot to respond to a specific message. Here the message that the bot will respond to is the “Intro.” If someone types this, in the console then he would get the message from the bot as “ Greetings welcome to the server.” You can change this message in the code. Remember that this message would only flash if the command has been used in a service who have the bot.

So save the text as the “bot.js.” Move the file to the folder of discord.

Cmd operation

Open the command prompt by pressing windows button and R. After that type cmd and hit enter. The command prompt window will open. After that, you have to type “cd\.” Then you would have to find the path of your bot folder. “cd\Users\Phil’s Desktop\Desktop\DiscordBot. This is an example; if you have the bot folder or location other than this, then you can change that accordingly.

cmd operation-min

Using cmd to install dependencies

Now use the node.js. While your folder is on the cmd, then the path line is “npm install discord.io Winston –save.” Now, this command would install everything that you need, the dependencies.

: npm install https://github.com/woor/discord.io/tarball/gateway_v6

You would get all the files that you need.

unsig cmd to install dependencies-min

Run bot

Now you would have to run the bot. To run the bot type, “node bot.js” in the cmd. This has to be done with your destination folder on cmd. Now test the bot through typing “intro” in the panel.

run your discord bot-min

You would get the message you have set. Congratulations, you are done with the bot.