Sign in
Log inSign up
The bot to my discord

The bot to my discord

Dominick Ugas's photo
Dominick Ugas
·Nov 14, 2021·

3 min read

Discord, honestly a must have platform if you game but also a great platform to use to have groups to just hang, work or study. Discord consists of servers, you could make them for a small group, a large on or join a public one for any purpose.

I personally use discord for all the listed options above but there is one thing I believe everyone needs in their server is a bot. It is by far the life of a party where you feel like you are with your peers just relaxing, but how do we get a bot into the server? Most people just download a bot from the internet, here I will explain how to create one!

First is first, we have to have the following.

•Ubuntu (for the windows users), Terminal(for the mac users)

•Node.js

•Visual Studio Code

After we make sure we have all these we can now jump into the fun part. We must start with creating a folder in our desktop (just call is Discord Bot).

Now that we have a folder we must put it within our ubuntu (or terminal). Open the ubuntu up, use the command explorer.exe . and when the window opens you can just drag the folder that we created on the desktop into this window(make sure you know where you are locating this folder).

CD commmand into the the folder command from our ubuntu(terminal) and use the npm init. There will be many questions asking you to put information. You can use mine as a reference:

image.png What all this did was make a json file. If you see the folder we created it should contain all of the information.

Awesome! From here we open up the folder within the Visual Studio Code with the command line code . and once we do, within the ubuntu terminal just run npm install discord.js. This will essentially be our framework. It will install all the modules that we will be using to code our discord bot.

Let's go back into our Visual studio create a new file named main.js

image.png

This will be the main file we will be working with as we build our bot. Within this file lets type out:

image.png

Line 3 will actually be our bot.

Before we go any further, let's go to discord developer portal in our browser (you must be signed onto your discord account). Once here click on the purple button where it says New Application and name it. After you name the application, convert it into a bot.

image.png

Once you convert your app into a bot you will be given a token. This token is basically a password that will allow some application we are coding to communicate with discord portal.

Next we will go into discord's API and give all the permissions the bot needs to do bot things.

image.png

Where it says client id you must paste the token that is generated for you.

image.png

image.png

When you paste the token in the Client Id it will generate a link underneath it, go ahead and click on it. This is going to allow you to add the bot to any server you have permission to.

Go back to the Visual Studio and at the bottom you will need to write client.login('token goes here').

Lastly you will need to go to your terminal to activate the bot. You could either run node . or node main.js.