How To

What is a Discord Bot: How to Make a Discord Bot

The Discord Bot is a trusted bot creating a community. Discord has a wonderful API for writing custom bots, and a really active bot community. You will need a touch of programming knowledge to code a bot, so it isn’t for everybody, but luckily there are some modules for popular languages that make it very easy to try and do. We’ll be using the foremost popular one, discord.js. Today we’ll take a glance at the way to start making your own.

What is a Discord Bot
Discord Bot

Discord Bot

Discord has an application platform on mobile for users as well as an online website. So, it is easy to connect to the Discord Bot on both the mobile app and on the app. If you desire to get a good bot maker platform, then this is your answer. Hope in the platform now and get your bot created.

How to Download the Discord app

Here is how you can download the Discord App:

  • Go to your mobile device app store.
  • Enter the title Discord on the search bar, and search for it.
  • Scroll and tap on Discord.
  • Tap on Download or Get the app.
  • It will be installed on your device.

After which you can access the service and features of the app straight from your device.

How to Create your Discord Bot

Step 1: Download Node.js and founded a Discord account

Node.js could be a JavaScript runtime that’s free and open-source, and you’ll need it to really make your bot work. Download it at Nodejs.org and install it before you start on the rest.

Obviously, you’ll also need a Discord account, and your own server to use to check your bot. If you haven’t created one yet, attend Discord.com and build one. If you are doing have one, log in to your account and open up the server within which you wish your bot to measure.

You’ll also need a text application, like Notepad++ on Windows, to code with.

Step 2: Create your bot

Now you’ll have to create an “application” on Discord to form your bot work. This takes a touch doing, but it’s not too difficult. The goal here is to achieve an “authorization token” for the bot. So that Discord recognizes your code and adds it to the bot on its servers.

First, head to Discordapp.com/developers/applications/me. Your account should be logged in, so you’ll go straight to your account’s list of applications. Hit “New Application” to start the operation. Give the bot a reputation, then click the button option as Save Changes.

Now, on the right-hand menu, click Bot. Once within the new menu, click Add Bot under the Build-a-Bot option. If you merely have one application the one we just made it should appear automatically. Otherwise, select it.

Step 3: Get your bot’s authorization token

In the box marked App Bot User, search for the words Token: Click to Reveal. Click that link and you’ll reveal a string of text. That’s your bot’s authorization token, which allows you to send it code. Don’t share it with anyone that token allows whoever has it to make code for the bot, which implies whoever has it can control your bot. If you think that the token has been compromised, the nice news is that you simply can easily generate a replacement one with the Generate a brand-new Token button. shave your token. You’ll need it in barely a second.

Step 4: Send your bot to your server

Now scroll up to the box marked App Details and find your Client ID, a protracted number. Copy the amount and add it to the present URL, within the place of the word CLIENTID.

https://discordapp.com/oauth2/authorize?&client_id=CLIENTID&scope=bot&permissions=8

The final URL should seem like this, but along with your client ID number in it rather than this fake one:

https://discordapp.com/oauth2/authorize?&client_id=000000000000000001&scope=bot&permissions=8

Copy the URL together with your client ID number in it into your browser. That’ll take you to a web site where you’ll be able to tell Discord where to send your bot. You’ll are aware of it worked if you open Discord in an app or in your browser and navigate to your server. The channel will say a bot has joined the area, and you’ll see it on the correct side menu under the list of online members.

Step 5: Create a Bot folder on your computer

While you’re doing that, you’ll also take a flash to form a folder in an easy-to-reach place on your computer where you’ll be able to store all of your bot’s files. Call it something simple, like “DiscordBot” or “MyBot,” so you recognize exactly what it’s.

Step 6: Open your text editor and make your bot’s files

You’re visiting to create three files for your bot from your text editor. within the first, paste this code:

{

“token”: “Your Bot Token”

}

Replace “Your Bot Token” with the token you generated earlier on your bot’s application page. confirm the token is inside the quotation marks. Then save the file into the Discord bot folder you made on your desktop, using the filename “auth.json.” Remember to not put it aside as a .txt file — it won’t work if it’s .txt rather than .json.

Make a replacement file, and put during this code:

{

“name”: “greeter-bot”,

“version”: “1.0.0”,

“description”: “My First Discord Bot”,

“main”: “bot.js”,

“author”: “Your Name”,

“dependencies”: {}

}

Replace the author name along with your name if you wish; you’ll be able to also change the “description” to something else if you want something more in line with what you’re making, which is able to be handy for remembering what your bot is meant to try and do.

Save this file as “package.json” in your Discord bot folder.

Step 7: Define your bot’s code

There’s yet another computer file to form, and this is often the important one that controls your bot’s behavior. You’ll want to be aware of JavaScript to essentially have full control of your bot and know what you’re doing, but if you’re new coding and just want to create something, you’ll copy and paste this code into the file to create an easy bot which will greet you in your 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.username + ‘ – (‘ + bot.id + ‘)’);

});

bot.on(‘message’, function (user, userID, channelID, message, evt) {

    // Our bot needs to know if it will execute a command

    // It will listen for messages that will start with `!`

    if (message.substring(0, 1) == ‘!’) {

        var args = message.substring(1).split(‘ ‘);

        var cmd = args[0];

        args = args.splice(1);

        switch(cmd) {

            // !ping

            case ‘ping’:

                bot.sendMessage({

                    to: channelID,

                    message: ‘Pong!’

                });

            break;

            // Just add any case commands if you want to..

         }

     }

});

This code sets up a Discord bot that may reply to certain messages: Specifically, anything that starts with a “!” character. specifically, we’re programming the bot to retort to the command “!intro”, so if anyone types that in your server while the bot is in it, the bot will respond with a programmed message. In our code, we defined the message as “Greetings! Welcome to the server!” you’ll be able to change both the prompt message and also the response message by redefining them within the code above. Just ensure to keep up the only quotation marks round the messages.

Save this last document as “bot.js” in your Discord bot folder.

Step 8: Open your computer’s “Command Prompt” and navigate to your Discord bot folder.

On a Windows PC, you’ll easily get to the electronic communication by clicking the Windows icon and typing “Command Prompt” within the field. Once it’s open, type “cd” followed by the file path to your folder. On our test computer, the command seems like this: “cdUsersPhil’s DesktopDesktopDiscordBot.” that ought to change the electronic communication line to incorporate the file path to your folder.

Conclusion

Alternatively, you’ll be able to navigate to your folder in Windows and hold Shift while right-clicking on a blank area of the folder, and selecting Open electronic communication.

Comment here