Make Discord Bot: Discord is one of the best sites to communicate with your gaming friends. Discord offers a lot of features to its users, also you can use bots to unlock more features on Discord. Here, a lot of bots are available to access. Discord allows its users to access as well as create new bots. Yeah! with Discord, you can easily create a new bot to use for you or other users too.
What are the Elements you need to Create a New Discord Bot?
If you using Windows, you need Atom, Sublime Text, and Notepad++. For Mac users, you can use Espresso. Also, you have to install Node.js and Discord on your Desktop.
How to Install Node.Js?
To create a Bot, Node.Js is one of the most important things. You can easily install it from its official website. To access Node.Js on your desktop, follow the below steps.
Firstly, go to the Node.Js official website.
Download the Node.Js from the website and run the installer on your desktop.
After the successful installation, open the CMD window and enter node -v.
It will display the version of Node.Js on your screen if you install the Node.Js correctly. Or else, it will become an error.
Read More – How to Fix Discord No Route Error?
How to Install and Create an Account on Discord?
You may existing a user of Discord. If yes, you can skip this procedure. Or else, you don’t have an account on Discord, then follow the below steps.
Go to the Browser and visit Discord’s official website.
From the website, Download Discord.
After that, install Discord on your Desktop.
Then, create a new account on Discord with all your right credentials.
That’s all, now you are successfully join to Discord. To learn more about the installation process, you can use How to Download & Install Discord?
How to Create a Server on Discord?
Creating a server is only for testing purposes. To know your Bot is working well or not, you can use a server. If you want to create a new Server on Discord, use the below guide.
On your Discord screen, you can see the +icon below the Home button.
Click on the + button and create a new server on Discord.
After the successful creation, you have to give a name to your server.
Now, you can access your Discord Server easily. If you want to know more information regarding Creating a new Server, you can check How to Make a Discord Server?
Also Read: How to Fix Discord Not Installing?
How to Make a New Application?
Now, you create a bot, and you want to access your bot on Discord. But, How did you do this? To access your Bot on Discord, Firstly, you have to create a Home Page for Bot. You can use Discord’s Developer Portal to set up your Home page. Follow the below procedure to use your Bot on Discord.
Firstly, go to the https://discord.com/developers/applications/me.
Then, log in with your Discord account.
If you create your first bot on Discord, your dashboard will be empty. So, you have to Select the New Appliaction option.
Now, enter the Bot Name and select the Bot Tab.
Then, click on Add Bot and select Yes, do it!
Read More – How to Fix Discord Can’t Hear Anyone?
How to Create a Discord Bot?
Now, we are coming to the major part of the project. Here, we are going to create a new Bot simply. So, follow all the instructions correctly without skipping.
Firstly, you have to create a new folder or project space where you will be storing the files of the bot that you are going to create. Select the Name and Open the CMD on your screen. Now enter,
mkdir “your bot name”
You have to enter your bot name on your bot name column. For example, here we are going to take a Bot name Discord Bot.
To go to the newly created folder, you can use the below command,
Then, initialize your project to get the .json package file. To initialize you can use the below command.
npm init -y.
To install discord.js or also called a library for Discord API, use the below command.
npm install discord.js.
Or else, use
npm install –save discord.js dotenv
If you want to access your Bot, you should have a unique ID for Bot. This ID is provided by Authorization Tokens. To create a file that is called tokens, use the below command.
For Window CMD,
For UNIX-based systems,
On Discord Developer Portal, you can easily find the Authorization token. Go to the Application and select the Bot Tab. Click on the Click to Reveal Token or Copy. After that, open the token.env file.
Go to your Discord Bot and open it on your code editor which you used on your Desktop. Here, we are using Atom editor. To paste the token, make use of the following command,
Dicordbot_Token=”paste the bot’s token here”
Go to the Command line and type,
Then, go to the Project folder and find out the .js file. Open the .js file on your device. It is the most important and basic step to create a Bot. You can use any template to create a Bot if you had no JS knowledge. You can use the below-given template.
Just use this template for your bot.js. Then save and exit.
Now, call the bot using the Command line. To call, use the below command
If you follow all these steps correctly, you will get a log-in page. Or else, you can see an error prompt, if you get an error, you have to add the token to the .env file. Then, follow the above steps again.
Also Read: How to Fix Discord Won’t Open?
How to Add your Bot to Discord Server?
Now, you can easily check your Bot is working well or not on your Server. To do that, follow the below process carefully.
Go to the Developer Portal and open the OAuth2 tab. Here, you have a lot of options and you can adjust them.
Certainly, select the Scopes option and choose the Bot button.
Scroll down the page and you can see the Bot permission. Here, you can see different kinds of features or authority. Select the feature to add to your Bot.
In moderation Bot, you will give permission to ban, kick and manage members. Now, you can select the Read Message History and Send messages option. If you get more knowledge in JS, then you can easily access all advanced options.
Then, go to the Scopes again and copy the link placed bottom of the page. It will direct you to the Discord server where you want to connect your Bot. Now, Authorize the connection.
Certainly, after that, go to the project and edit discordbot.js. Still, we didn’t add any commands to the bot. So, we want to add some code to access your bot on the Discord Server. Use the below template to do this process.
To cancel your previous discordbot.js, restart your command line. You can use the Ctrl+C shortcut also. But, it is not workout for all time, especially on Windows cmd.
Go back to the Project Folder and enter the below command.
It will direct you to log in to the updated .js. Now, go back to the Discord application on your Desktop and test the bot.
From the above process, your Bot will respond to the Hi message as Bye.
If you see the Bye, Congrats you have done great work. Now, you can add any feature that you want on Bot.
Also Read: How to Appear Offline on Discord?