So you are new to development, I mean you are new to bot development and want to develop a Discord Bot reading and keeping this article as guidance. So let me share a small story with you when I started developing a Discord Bot I had no one to give me the guidance I didn’t even take any classes for programming. I started working on the bot looking to the guide provided by the Discord.Js Org and Youtube Videos Related to the Discord Bot Development. I am not sure if will not get any error or problem after reading this article completely while developing a bot. The reason is discrod.js are updating and making them better day by day. But I am sure that I will try to minimize all errors that you might face while you will be coding.
Requirements before Developing the Bot :
Let’s Get Started
Now I hope you have downloaded and installed the software I have mentioned above in the list. If you had any problems while installing the software let me know in the comments so that I can include the solutions in the post itself. Now to check if the node.js have been installed on your computer or not I want you to type node -v after opening Command Prompt on Your Computer (Windos+R type cmd then hit Enter.)

If you see the Version number as shown in the image given above rather than an error then you are good to go. Also if you get any errors try reinstalling and make sure to click on the box of Install to Path option while installing.
You might be thinking about what to do after this. Create a new folder on your desktop. Now open the folder and click on the address bar. Replace the file location by typing cmd and hit Enter.

After you see the Command Prompt Window, Check If the location shown in the Cmd is the same as on your folder you have just created for the development of the bot. After that, open the terminal type in npm init -y then hit Enter. After that’s done New File will be automatically created on Your Folder. Now Open the file using Visual Studio Code that you have downloaded from the list mentioned above. Add the description and author only if you want. Now Open the folder in Visual Studio Code and Open the Terminal You can Use the Shortcut Key (Crtl + Shift + `) or go to the Terminal Tab and Click On the new Terminal. Now type in npm install discord.js hit enter.

Then type npm install eslint and hit enter. Now go to the extension tab on the VS Code and install the ESLint by Dirk Baeumer. Create a file name with .eslintrc.json and paste the code from here.
Now let’s do the easy part go to Discord Developer Login through your discord username and password then create an Application. And after you are done with setting up the name and your favorite avatar you go to the bot tab and create a bot and be sure to copy the code of the bot you will need later. Now chose the OAuth2 tab and click on the bot box and about the permission for now set it to Administrator and invite the bot to your server through the link that will be shown above.

Now let’s go to the fun part of codding the bot make a file with the name index.js. The reason for making the index.js as a file because we have written on package.json the main: index.js. You came to change the name of the file but be sure to change the name on the package.json also. Be careful while coping with the codes below.
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Hehe Boi I am Online!');
});
client.login(your_bot_token_code);
Be sure to replace your_bot_token_code with the code you have copied from then Discord Applications before and also keep in mind that the code must be in between the small bracket. And now again open the Terminal and hit enter after typing “node .” yes there is space between the node and the ‘.‘

Now after the bot is up we are ready to add some command and let’s get the bot online and start the commands. Firstly add new command Names Ping when we type the ping on discord the bot will respond with “Hey! Why did You, Ping, Me?”.
client.on('message', message => {
if (message.content === '!ping') {
message.channel.send('Hey! Why did You, Ping, Me?');
}
});
Now paste the code above in between the end of console.log and client.login for the response you will get after entering !ping on the discord message. The bot will reply with the text inside ‘ ‘. Also, you must close the previous terminal after you make some changes to the code and start it again to get the output.
else if (message.content === `!user-info`) {
message.channel.send(`Your username: ${message.author.username}\nYour ID: ${message.author.id}\n Account Created On: ${message.author.createdAt.toDateString()}`);
}
You might be thinking about what does the code above does and where to place this code to make it function well. So the code above gives you the output of your Discord Username, Discord ID, Date of Account Creation. The “\n” means the next line. This means all the output after \n will be shown in the next line. Again as you know you must terminate the previous terminal and start the new one using “node .” then you are good to go. I have also linked the latest discord.js video playlist and the discord.js guide. So that your time on coding will be easier.
[…] Here are few Secret Features of Discord if you know more about the Hidden Features of Discord then I would love to see them in the comments below and I will be surely updating this post and adding new features in the coming days. Also if you are a Music Lover and love to sing or listen to Song then You can join the server given below. Do you want to develop your own Discord JS Discord Bot? […]