Skip to Content

How to Make Discord Bot? [Step by Step Guide]

Sharing is caring!

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.

Normally, bots give tons of features like automatic moderation, playing music, hosting text-based games, and so on. Creating a bot is a simple method when you know the coding. Mostly, everyone uses Python or JavaScript to create a bot. So, here we are going to show the simple tricks to create a new bot easily. 

What are the Elements you need to Create a New Discord Bot?

Before going to the bot creation process, you must have some criteria like basic knowledge in Python or JavaScript. Also, you have to download any code editor to create a code.

Yourtechlist Holiday Sale Offer

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.

Make Discord Bot
How to Make Discord Bot?

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.

Step 1:

Yourtechlist Holiday Sale Offer

Firstly, go to the Node.Js official website.

Step 2:

Download the Node.Js from the website and run the installer on your desktop. 

Step 3:

After the successful installation, open the CMD window and enter node -v.

Step 4:

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.

Step 1:

Go to the Browser and visit Discord’s official website.

Step 2:

From the website, Download Discord.

Step 3:

After that, install Discord on your Desktop.

Step 4:

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.

Step 1:

On your Discord screen, you can see the +icon below the Home button.

Step 2:

Click on the + button and create a new server on Discord.

Step 3:

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.

Step 1:

Firstly, go to the https://discord.com/developers/applications/me.

Step 2:

Then, log in with your Discord account.

Step 3:

If you create your first bot on Discord, your dashboard will be empty. So, you have to Select the New Appliaction option.

Step 4:

Now, enter the Bot Name and select the Bot Tab.

Step 5:

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. 

Step 1:

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.

Step 2:

To go to the newly created folder, you can use the below command,

cd discord-bot

Step 3:

Then, initialize your project to get the .json package file. To initialize you can use the below command.

npm init -y.

Step 4:

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

Step 5:

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,

call>>.env

For UNIX-based systems,

touch.env

Step 6:

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. 

Step 7:

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”

Step 8:

Go to the Command line and type,

call>>discord.js

Step 9:

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.

Discord-bot
Discord-bot

Just use this template for your bot.js. Then save and exit. 

Step 10: 

Now, call the bot using the Command line. To call, use the below command

Node discordbot.js

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. 

Step 1:

Go to the Developer Portal and open the OAuth2 tab. Here, you have a lot of options and you can adjust them.

Step 2:

Certainly, select the Scopes option and choose the Bot button.

Step 3:

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.

Step 4:

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.

Step 5:

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.

Discord Bot Reply Command
Discord Bot Reply Command

Step 6:

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. 

Step 7:

Go back to the Project Folder and enter the below command.

node discordbot.js

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?

Conclusion

You can use Bot on Discord to access more features. Likewise, you can also create a Bot with Discord easily. It need only basic knowledge in JavaScript or Discord. In this article, we explain the simple procedure to create your own Discord Bot at your wish. Use the above-given guide to create a new Bot. You can add your favorite features to Bot without any limitations. We hope this article will be taught you the procedure to create a bot in an easy way.

Tags
Yourtechlist Holiday Sale Offer