discord bots

Latest Discord Bots Making Guide 2020

What is a Discord bots?

A discord bots, to summarize, is a programmable application with C ++, Python, Ruby, PHP, JavaScript, etc. That is connected through an individual account to Discord, and you can use it in Servers to deliver content, utilities, listen to music, laugh and other things that language can allow. Instead, it is like your application, but available to all those who want to use it.

What Will We Need How To Make a Discord Bots?

In this post, we will work with Javascript, and the corresponding library: Discord.js, a simple library suitable for starting in the world of bots. It is importing for how to make a discord bots.

We also need:

Let us begin how to make a discord bot

Step 1) Creating the Discord Bots

We are going to create the user who will use the discord bots to be able to work. So we go to the following website with our discord account already logged (if you do not create a new account and enter) once that is done.

You will take us to this page:

“Create a new application.”

Discord bots

Then it will take us here, where the parameters to be configured (and mandatory).

  • Name of our App or Bot (Required).
  • The description of our bot (This is not to be confused if you have many bots, and to take into account what the bot is for) If you want, you can leave this field empty.
  • 3) The profile image that our bot will have.

How do I upload the profile picture? We click on the little camera next to the small circle where the profile picture is supposed to go. A window will open where you should choose an image.

I will choose this image to download from there; likewise, at any time, it can be changed even after the bot is created.

Finally, we click on “Save Changes.”

If we get this confirmation, we will have our first complete step.

Discord Bots section

Now, we have our base for the bot made in discord, now we only need to give it the “magic” to have a place in Discord, so if you look at the sides of that same page, you can see a few sections, let’s go to enter the “Bot” section:

It will take us to the page shown in the image below, and now once it is finished loading, you click on the “Add Bot” button to create the user in Discord for that button.

Short Brief in Discord Bots Section

discord bots

What the message says is that if you believe it, this user will be permanent for a lifetime and cannot be deleted, and it is irreversible and tells you to choose carefully, this is so that you are sure of what you are doing since there are people, who go, create the user and the project is nowhere.

Once we decide to do it, click on “Yes, do it!” or “Yes, do it!” Now create the discord bot user.

Now we will explain the following sections that will appear, and you can understand exactly what you are doing.

  • 1) The photo of your bot: This is automatically filled in with the picture we previously put for the bot, but if you decide to change it in the future for one reason or another, here you have it.
  • 2) The public username of your bot: This username will appear publicly in Discord, you can change it if you wish in the future.
  • 3) The #TAG or user number: I do not know if it can be changed, I think this number is unique for each account that has Discord Nitro.
  • 4) Token: (Later in this post we will explain it)
  • 5) Public Bot (Define if it is a free discord bots or a private discord bots): If it is marked/activated, anyone who owns the link to invite it will be able to add the bot to their server without problems. Everyone can use it basically if it is unchecked/disabled; only you can authorize/add your bot to Discord servers. It gives you more control in case your bot is still in development, and you do not want other people to add it to their servers.
  • 6) Requires an OAuth code grant: If marked/activated, only users will be able to add your discord bots when an authentication code is provided, better known as “Token OAuth2 ” or only ” OAuth2 token” to the invitation link of your bot, this offers more security and control depending on the circumstances that you will use, in this tutorial, we will not use it.
  • 7) Bot permissions: These are the permissions of your bot, what does this mean?
  • It is to tell the owner of the server that when adding it, the system will automatically add a “special” role for your bot where the capabilities that your bot needs to function correctly will be included.

I Give You Some Examples About Discord Bots Permits Section:

  • – If your bot is going to have a function or capacity that requires it to connect to a voice channel (such as to play music), you must check the options “Connect,” “Talk” and “Use voice activity” for your bot CONNECT to the voice channel, you can TRANSMIT the sound and LET the others know that you are doing it.
  • – If your bot is going to have the ability to delete messages (As a function to delete unwanted messages) Maybe you should check the “Manage messages” box; this will give your discord bots permissions to remove them and even edit their content.
  • – If your bot is going to have a function that will add reactions to user messages, you should check the option “Add reactions.”
  • – If your discord bots are going to have the ability to kicker / ban people when they do something they should not do, you may have to check the box “Eject Members” (to kicker) and “Ban Members” (to ban).
  • – If your bot has to use all the permissions shown in your list, you can check the box “Administrator,” this will grant you all the leaves shown in that list.

Now, there is something significant that you should know about these permissions. There are some permissions that you cannot go and mark them, and you will already have access to them. Authorities such as “Manage Roles,” “Manage Server” or even the master role “Administrator” is not given to anyone for their bots (since malicious advertising or spambots are usually made) and to activate them you need to verify or add a cell phone to your account as a double authentication factor “2FA” or add a 2FA authenticator certified by discord to your phone (Android, IOS, etc.)

With respect to the other roles, you can use them freely, and their meaning is explained alone.

8) Permissions integrator: This will be the code resulting from what you mark above, it will be added to the invitation link of your bot, if you do not add that number to the link, the owner of the server that will add it, will add your bot without the permissions you marked above.

For this guide, we will check the box that says “Public Bot,” this is so that anyone can add your discord bots to your server without requesting authorization (obviously as I said before).

How To Add Discord Bots To Discord Server

how to add bots to discord server

How To Add Bots To Discord Server, We must create an invitation link, and it’s not a big deal, it’s effortless to create it!

Copy the link and paste it into the browser: https://discordapp.com/oauth2/authorize?&client_id=(go to “general information” section  and copy and paste here Clint ID) & permissions = (Got to bot section and go to the “Bot Permissions” select your desired option and  copy “PERMISSIONS INTEGER” number and paste here ) & scope = bot

We will copy the ID of your bot: Yours may vary from the one shown here. In my case, that is the ID of my bot

Copy it and replace the existing text in the “client_id” parameter of the link, like this:

Then we go to the Permissions Integrator and copy the number generated by marking the permissions that our bot will need:

And replace the existing text in the “permissions” parameter like this:

And voila, now we put it in the browser:

We will get the following page, here we select the server where we want to add the bot user that we create, I will choose the server “Tests” that you create for this occasion:

And if we check below, we will see the permissions that we will grant to our bot on the server:

And then click on “Authorize”:

And we review the authorization box to prove that we are not another crap bot:

And ready friends, the bot is already added to our server but go to your server in Discord and look.

The next task would be to go to discord, we will see that there is a new member on the server, but it is disconnected, that is our bot.

You can also add the bot on any server where you have an Administrative rank, or ask an admin of a server to add it to you, always giving the link you generated previously so that they can invite you to the bot.

Step 2) The Token: Making a Discord Bot

how to make a discord bot

Very well, we learned to create a space for our bot, we could add it to the server, etc. But, now you have to program it to work, if not it would be worth having a bot that does nothing?

For that, we will start programming (in JavaScript) our first bot.

First of all, we will return to the information page of our bot and go to Bot> “Click to reveal token,” where is the “Token” section we had seen before.

And he will give us the following text:

This is our token, and the token would be our exclusive email and password. So that the program that we are going to do in JavaScript accesses the bot user that we have created, this token. You should not share or spread to anyone. Since another person could use it to place your script/application in your bot and supplant. Its operation (which ranges from collecting user information to sending spam to banning and kicking all users of your server out of nowhere).

In case you have revealed it by accident and do not want to take a risk, press “Regenerate” and accept all warnings to generate a new token. It will disconnect your bot and any other that shares the same token and will not work while replacing the old token with the new one in the code.

Copy and paste the token into a google chrome or any browser, and keep it in a safe place, since later in this post it will help us to finish the discord bots.

Step 3) Programming (node.JS) For Discord Bots.

discord bots

Now to start programming the bot, we need to download the Node.JS a platform that will allow us to execute the JavaScript code on our PC, you can download it by accessing its official website:

Choose the bit version that we have in our PC, 32 or 64 bits

How do I know if I have a 32 or 64 bit PC?

Step 1)

Right-click on “Computer” in the Start menu and select Properties.

Step 2)

A new window will open where in the section that says “System Type” you can see if it is 32 bits or 64 bits.

Now that we know that our PC is 32 bits (in my case), let’s choose the 32 bit version

The download of Node.js, weighs only 15MB, to install it, just double click on the .msi file

Probably you will see the following window, where we have to run, to start the installation.

Install Node.js and Prepare Discord Bots.

Latest Discord Bots Making Guide 2020

It is very easy to install, Just click install (As like other normal software)

Well, once installed, we create a new folder in an easy-to-access place, make sure that this folder is empty, and does not contain symbols or spaces in the name.

And in the space of the folder, press CTRL + SHIFT and while holding it right-click to open the context menu and select the option that says “Open command window here.”

Once this is done, the following CMD or command console will open.

Now we write the following: “npm init” (Without the quotes)

We will ask the name of our App, and we will write the name but without using capital letters!

I will put the name of my bot, bone “testbot” without the capital letters and press Enter to send the answer:

Then we will ask the version of our app, by default it is in 1.0.0, we will leave it just like that and press Enter, to leave that part empty.

It will ask us to describe our app; if it is necessary, do not put anything. It is only referential, press Enter.

Now we will ask for an “entry point,” this is the main file of the application that node will handle, by default, it is in “index.js” so we leave it that way no more and press Enter.

We will ask for a “test command” or test command, and we do not put anything, just press Enter.

We will ask for a GIT repository, for those who do not know what the fuck this is, it is a place where developers or (“programmers”). Upload their code publicly, and people are free to contribute their grain of sand in the code. This is only optional unless you later want to share the code for help.

In my case, I will leave it empty, and press Enter

He will ask us for keywords or “keywords” to identify our project, leave it blank and continue

Now we will ask the author of the application, and we put there our name or our username

Now we will ask for a license, do not worry, this would be the license that will be under our project, in itself, the node.js is free.

By default, it is set to “ISC,” so we leave it blank and continue with Enter.

Finally, we will ask if we want to write the data of the new application, say “yes” and press Enter to write the changes.

And we will have finished the template of our app

best discord bots

Now we will install the discord.js library in our project. Which is indispensable for the operation of our bot so that we will execute the command “npm install discord.js –save” (without any quotes) and press enter to execute the command.

We wait a few minutes until the library is downloaded (about 20kb) in the folder. The final result would be similar to this:

If we return to the folder, we will find that it is no longer empty, and there are new files:

Now we will open a new browser tab and select File> Save As…

In the drop-down list of “Type:” we will select “All Files (*. *)

And name it “index.js” (without the quotes) and save it along with the other files in the folder.

The final result of the process would be this:

Well, in the index.js file, it will be your bot, there you can program all your behavior, and the main responsible for its operation, and the file is somewhat empty, so let’s start programming.

(Don’t forget to end each line of code with a semicolon “;”

The console.log is to send the quoted text to the console from where we run it, in this case, when the bot is executed, and it will print on the console “The bot is ready to sweep.”

We will create a record, called Discord that requires the module “discord.js.”

We will create another record in another line called “bot,” this will trigger a new Discord client, “Discord.Client ()”.

Be careful with this step, double-check before continuing, it is not “Discord.Client ();” if it is not “Discord.Client ();”. Many people asked me for errors in the execution of the bot that have to do with this simple spelling error in the code. That can burn many people’s heads, pay attention to the text I write and the image. (Obviously, because this edited does not see much the difference between upper and lower case.

We are going to create a new event called “message” within this event will be all the actions that the bot will do during your routine. If you have noticed, I have left an empty line between the lines that make up the event, and this blank line. We will press the TAB only once (since we are in the presence of square brackets)

For those who do not know what the TAB is, this is:

Now, we can write the orders or activities that the bot will do, first of all, we will make the bot say something when it detects a word or phrase in the chat so that we will make an “if” statement.

Where message.content refers to the function to capture the messages of all the channels. Where the bot is attached, and in quotes, we put the word that will trigger the action below, “hello.”

Now, we must specify to the bot what it will do when it detects the word, so we open a new line with ENTER, as we put square brackets after the “if” statement, we must press the TAB 2 times to write the action to be taken, so

Now, we will write the step to take:

Where message.channel.sendMessage, is to send a text message through the same channel where the word configured in the “if” above was detected, and in quotes, we write the message that our bot will respond to that action.

Now, on another line, we will press TAB once and put a square bracket to close the if statement

Now we specify everything the bot will do, but we forget to specify which discord account to access, so under all, we will open a new line, and put the following:

I hope you saved the token of your discord bots because between the quotes, and you should replace the text, with the token.

Being that way:

Step 4) Turning on The Discord Bots.

Well, it’s time for the litmus test, it’s time to make our precious bot discord walk.

So we will save all the changes we made in the index.js file.

And we go back to the console and write “node.” (Without the quotes) to execute the .js file, and therefore the bot discord.

You will know that the bot is ready when the console.log function takes effect:

If we return to discord, we will see that our discord bots are already online:

Now, we will write “hello” to see if the bot can answer us.

Success!!! Our discord bots are ready and fully functional!

Step 5) Adding More Functions Make Smooth Discord Bots.

If you need to modify the code to add more functions, for example, detect more phrases, make functions in useful JavaScript, or to solve bugs, the bot always has to be restarted to take the most recent changes, let’s see an example:

  • We modify the current code with more functions:
  • We go to the console and press the key combination, CTRL + C to end the execution of the code and then write again “node.” to turn it on again For those who do not know how the CTRL + C is done.
  • We tried the new thing we put: (the images are from last year, but they show that it works, that is, the same thing works now, do not worry, it only gave me a bit of laziness to change more than 74 images, but I made it as understandable as possible )

Step 6) Make JavaScript Functions For Discord Bots

The bot is also compatible with certain JavaScript functions outside of discord.js, and we will make the bot throw a random number:

  • We write the code. The functions of Math, JavaScript are perfect for the occasion
  • B) Save the file and restart the discord bots.
  • Now your bot has a function to throw random numbers from 1 to 100.

And that’s all ambiguous, the world of JavaScript is quite finite in possibilities, so the only limit is your imagination to achieve it, then I leave the discord.js wiki where you will find all the functions offered by discord.js

Discord.js Wiki

Conclusion

If you have followed my guide, I think you haven’t any problem with how to make a discord bots or how to add bots to discord.

No Responses