I had recently written about the alternatives of MEE6 Bot. Now in this article, I will be helping you to create your very own discord bot. In today’s whole process of Creating a Discord Bot in 2021, we will be using discord.js. Please don’t worry if you are new to the term discord.js. I will be helping you with everything slow and clearly. So let’s being today’s process be sure not to skip any process and stay connected to the internet.
What is Discord.js?
Discord.js is an amazing node.js module with helps us to work with Discord’s API. It is the best discord library with helps us to make a discord bot easily. This helps us to sent and receive information through an access token received from the discord applications page.
Things you Need to Get Started
Before starting the process of creating a discord bot in 2021 let talk about the things that you need to start the process. Firstly make sure you have a fine computer with an internet connection. Now create a discord server where you will test the bot. If you are working make sure to invite your friends.
How to Create a Discord Server
Most of you here might well know about how to create a discord server. But some of you might be unaware of the steps to create a discord server. On the left bottom of the server’s icons, you might have seen a plus button. Click the button then chose the server template and enter the server name. Now you have your own discord server now you can invite your friends.
Creating a Discord Bot in 2021
Before moving to the details of developing a Discord Bot make sure to read all the articles and not miss a step. Not only that you also need to make sure that the version might deffer so be sure to use the same version information. I have divided the steps into few parts to make the whole process easier.
Creating an Application in Discord Developers
So let’s get started firstly go through the discord developers and login into your discord account. https://discord.com/developers/applications. Now after you are logged in you need to click on the New Application button on the left top of your avatar. Then enter the name of the bot and click on Create Button. Now click on the Bot tab on the left of the page. After that, you need to click on Add Bot now you have successfully created a bot of that application. Now you can change the name and logo of the bot as your wish.
Inviting Bot to the Server
Nextly invite the bot to the testing server you have created. For Inviting the bot Click on the OAuth2 tab and select scops to the bot. Also for now chose the bot permission to Administrator. You can easily change the permission of the bot in the future. Then copy the link and paste it in any browser where your discord is logged in. Then simply chose the server and complete the Verification now you have your newly made bot in the server. But wait the bot isn’t online and doesn’t respond. Don’t worry because the real work is on its way.
Downloading Command Handler
In this article, I will be showing you by downloading a pre-made command handler for the bot. The reason behind this is if you know how to don’t know how to deploy a bot why should increase the size of the article. So the best option for beginners is to download a pre-made command handler. Download the zip file of Command Handler from this link here. Now extract the zip file and rename the folder name with your bot name.
Downloading and Installing Node js
Now you better download and install the node js on your computer. You can download node.js from the link https://nodejs.org/en/download/ make sure to choose the perfect download package. For this full tutorial, I am using node v14.17.0. So if anything goes wrong you can try using this version of node.js.
Download and Install Visual Studio Code
You can totally skip this step if you have a better file editor or the Visual Studio Code is installed on your computer. You can go through this link to download Visual Studio Code. Also, I wanted to add some amazing extensions for the visual studio code that you can add. Firstly we have Beautify by HookyQR which helps you to make the code clean and align it perfectly. Secondly, you can add Discord Presence by Crawl to show that file you are editing in the rich presence of your discord profile.
Next what you need to do is open Visual Studio Code that you had installed in the above step. Now open the folder you had extracted of the command handler. Now you need to open the config.json file and go to the Discord Developer Portal from your browser. Then click on the Bot Tab and copy the token. Then paste the copied token inside the quotation mark(” “) in the config.json file in the line of the token. Also the prefix in the line of prefix inside the quotation mark.
Installing the Node Modules
The step before running the bot is installing node modules or npm for the bot. So the first npm or node module that you need to install here is ascii-table. For installing it click on the terminal on the top bar of VS Code and type npm i ascii-table in the console and hit enter. Now type in npm audit fix in the console to fix the node modules files automatically.
Running the Discord Bot
The last and the most amazing step in the whole process is running the bot. Now firing running the bot open console and type in node . make sure you have left space between the node and the dot (.). This also can bring a huge difference while running the bot. You might also see tons of errors if you don’t leave a space in between. Now finally how to know if the bot is running? If your bot is running you will surely see it online on the discord server. Secondly, you will see something like this in the console.
Then you have read the whole article on Creating a Discord Bot and made working and running the bot. It’s really cool that you have made it but if you have questions about what to do next and how to add some amazing ass-kicking commands do leave a comment below. Also If you don’t want to open the visual all the time to run the bot you can use this .bat file. Click here to download the .bat file. See you guys in the next one this then have a wonderful time and happy coding.