How To Make A Discord Bot: If you are into online gaming and have ever followed popular online gamers on platforms like Youtube or Twitch, then you must have heard about Discord. If you haven’t, Discord is a free and open-source communication platform for gamers which enables us to chat over messages and voice with multiple people at once.
One of the main features of Discord is discord bots, which are used by chat room creators to perform certain functions. Discord bots are automated tools that are designed to perform specific roles as programmed.
Read Also: 10 Best Discord Bots To Enhance Your Server
In fact, discord bots have become so popular in the last few years that new discord bots are being created regularly and also used by many. When it comes to discord, bots are one of the most essential parts of it. If you are fascinated by the term discord and are thinking about how to make a discord bot, then the answer is that it is fairly simple to design and very easy to use.
Creating a unique discord bot is easy, but if you want to download and use one which has already been created by someone, then you can go to the DiscordBots website and either develop your own or select from the list of already created ones.
Creating a discord bot is not difficult, but there are a few things that you should know and should be prepared to help you set up discord bots. The first thing that you need to do is to fill the prerequisites to create the bots. For that, you need to have a Notepad++ or a text editor software. Once you have it, make sure to have a Discord account and a Discord server to test the bot. Once you have all the three, you are ready to create a bot. A bot works as an automated robot that connects with your servers and accts in response to a specific event.
Bots are easily identifiable in the regular online channels, with a blue “bot” tag. Discord bot simply recognizes certain functions on your devices and acts to it accordingly. To make a discord bot one needs to have certain things on their system, which include, node.js, Notepad++ or simply Notepad in Windows, Discord account, and Discord server to test the bot.
Below are the steps on how to code your own discord bot
How to make a Discord Bot?
Now Discord will simply connect to the server and will act in response to an event. A typical bot comes with background code and programming that tells it to respond in a specific situation. For this to happen you first need to download the Node.Js software and create a discord account. Node.JS is one of the most important systems that you need to have in order to code a Discord bot.
It can simply be downloaded from the Node Js website and is free of cost. Once you do that, you need to create a new Discord account, unless you already have one. To create a new account, simply go to the Discordapp website. Login to the Discord account from there and launch the server where you want the bot to exist.
Create a program for the Bot
Once you have Node.js installed on the system and you have created the Discord account, the next step would be to create the program. To do so, you first need an authorization signature that will help the Discord platform to distinguish your code and unite it with other user bots connected to its servers. It can be done from the Applications page, under the developer’s menu on the website.
Simply select the new application option
Name the bot and save it
Getting the Authorization token
Now creating a bot for discord would also require you to get an authorization token. While you are logged in to the discord account, locate the App Bot Userbox for the “Token: Click to reveal” link. Clicking on the link will give you a text string that serves as a unique authorization token for the bot.
The token is what provides the owner the ability to generate code for the bot. Therefore, do not share it with anyone or they will have control over the bot. Also, if the token is expired or broken, a new one can easily be generated. Once done, go to the App details box to see your client id.
Copy those numbers and then add them to the link, in the space where the word “CLIENTID” is written. Your final client id will show the link with the Client ID number.
https://discordapp.com/oauth2/authorize?&client_id=CLIENTID&scope=bot&permissions=8
Using the link on the web browser will direct you to a web portal that will enable the Discord program and tell it where to send the bot. You will be notified but the channel that bot has entered the room and it can be seen in the menu on the right underneath the listed online members.
Create a “Discord Bot” folder on your PC
This would be a simple step for you where you simply need to create a new folder on the system, for storing all the files related to the Discord bot. This would make it easier for you to locate and search all the files.
Use a Text editor like Notepad or any other to create the program for Discord Bot
Now the steps that you have to do to create the Discord bit will be very crucial, so make sure that you copy each step and create your discord bot using the same commands. First, you need to create 3 separate files. Now open the first file and enter the below-mentioned command.
{
“token”: “Your Bot Token”
}
Replace the “Your Bot token” with the token that was generated in the previous steps. Once done, simply save the first file with the name auth.json. The only thing you need to make sure is that the file is saved as .json and not .txt
Now you need to use the second file out of the three and insert the command mentioned below.
{
“name”: “greeter-bot”,
“version”: “1.0.0”,
“description”: “My First Discord Bot”,
“main”: “bot.js”,
“author”: “Your Name”,
“dependencies”: {}
}
If you want, you can change the name of the author to your name or any name you like and even change the description. Now save the second file with the name package.json, making sure that file is saved with extension .json
Define the Bot
Now in this step, we need to create the third file, which is the most critical one and is used to define the behavior of the bot, which means as to what event the bot should take a particular action. This where the knowledge of Javascript comes into play.
However, if you do not know javascript and are still looking for answers for “how to code a Discord bot”, then simply use the code below which is a simple program that makes the bot welcome you to the server.
var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on('ready', function (evt) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.yourusername + ' - (' + bot.id + ')');
Use Command Prompt to go to the Discord folder
Open the command prompt window on your system and enter the discord file folder path after the CD command. After this, the command line will prompt the Discord file folder.
Once done, we will now start using the Node.Js program. In the Command prompt enter “npm install discord.io winston -save“. This command will install files in the Discord folder as per the requirements.
Run the bot
The final step to the process is to simply run the Discord bit. First, go to the command prompt window directing to the discord files folder and run “node bot.js“. If it works then go to the private server on discord and run it. If all goes well, the bot will respond to any coded message you have sent.
Conclusion: How To Make A Discord Bot
The process of discord bot making and running it may sound a little confusing and tough to you as it requires Node.js and an understanding of JavaScript and it may sound a little difficult for newcomers as well. However, once you start to make more bot, the process becomes a lot easier to use and apply in the Discord server.
Also, this discord bot tutorial can be used to add a lot of different functions to the Discord chat server. So try to make discord bots at least once using the methods and codes mentioned above and try to create a bot for the first time.
You may also like:
- 10 Best Discord Bots To Enhance Your Server in 2021
- How To Get Chegg Answers For Free – Unblur Chegg Answers [Bypass Guide 2021]
- How to Transcribe YouTube Videos Automatically (Stupid Simple Method) [2021]
- Fortnite Optimization: How To Increase FPS In Fortnite(6 Simple Steps)
- How to Recover Deleted WhatsApp Messages (1 EASY Method)
The post How To Make A Discord Bot (Easy Fail-proof Guide for 2021) https://ift.tt/3rPNNzz originally appeared first on WikiWax
No comments:
Post a Comment