Gaming

Know how to create a bot of Discord to keep active your channel

The rise of Discord, the program and voice chat preferred by gamers, has allowed that is common for Internet users to meet in their “servers” around various topics. But one of its most interesting features is the possibility to create users automated (bots) that serve various functions. Do you know how to create a bot of Discord? Here you explain it. As you know, Discord allows you to create your own server, set it up with different channels and invite the people you want. And the bots developed different functions in these chats, from play music to users, to greet the new members or detailing rules, among others. Make your own automated user does not require a lot of effort, even if you are new to coding. If you want to know how to create a bot for Discord, then you explain it step by step.

Step 1: download Node.js and you set up an account Discord

Before advancing in the guide of how to create a bot for Discord, I suggest you download Node.jsa JavaScript compiler is free and open source, and what you will need for your bot to work.

Obviously, also you will need a Discord and your own server to test your bot. If you still have one, log in to Discordapp.com and believe it. If you already have one, log in and open the server where you want to host your bot.

To encode you’ll also need a text editor, such as Notepad or Notepad++ in Windows.

Step 2: create your bot

Cómo crear un bot para Discord

Now you will need to create an “application” in Discord for your bot. This takes a little time, but it is not complex. The objective is to obtain an “authorization token” that Discord will recognize your code and add it to the bot on their servers.

Go to discordapp.com/developers/applications/me. You must have your account open, which will take you directly to the list of applications. Click New application, give a name to the bot, press the button Save changes.

In the menu right, click on Bot. In the following menu select Add Bot, under the option to Build a bot. If you have only one application, which we have just done, it should appear automatically. Otherwise, look for it in the list.

Step 3: get a token

Busca tu token en Discord

In the box labeled as User App Bot, find the Token: click to reveal. Click on the link and you will see a string of text. This is the authorization token of your bot, which allows you to send the code. Do not share it with anyone: who can create, modify, and control your bot. If you think that the token is at risk, you can generate another easily with the link to Generate a new token.

Save this number. What you will need it in step 6 of this guide on how to create a bot for Discord.

Step 4: send your bot to your server

Debes enviar tu bot al servidor de Discord.

Now scroll down to the box marked Details in the application and search for your “customer ID”, which is a long number. Copy the number and add it to this URL, replacing the word CLIENTID.

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

The final URL should look like this, but with your id number in place of the 22334455667788 that we can simulate:

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

Copy the URL with your id number in the browser and you will come to a web site in which will you say to Discord where to send your bot. If it worked, Discord will be opened in an application or in the browser and show you the server. The channel will say that a bot joined the room, and what you’ll see in the right side menu, below the list of members online.

Step 5: create a folder in your computer

Es recomendable crear una carpeta en tu computadora para almacenar los archivos de bot

We also suggest you to create a folder easy to access on your computer to store all the files of the bot, something like “DiscordBot” or “MiBot”, so that you know exactly what it contains.

Step 6: create the files with the text editor

Debes crear tres archivos con algún editor de texto.

You’re going to create three files for your bot from your text editor. First, paste this code:

{
“Token”: “Your token bot”
}

Replace “Your-token bot” that generaste above. The token should be inside the quotation marks. Save the file with the name auth.json in the folder of Discord of your computer. Important: do not stores like .txt, because it will not work.

Creates another file with this code:

{
“name”: “greeter-bot”,
“version”: “1.0.0”,
“description”: “My first bot of Discord”,
“main”: “bot.js”,
“author”: “Your name”,
“dependencies”: {}
}

Replaces the author name and changes the description, which will allow you to remember what makes your bot. Save this file as “package.json” in your folder of Discord.

Step 7: define the code

You will need a third file is vital to the behavior of your bot. You’ll need to be familiar with JavaScript to have a total control of the bot, but if you’re new to coding and just want to do something simple, you can copy and paste this code to make a simple bot that will greet you on your server. (Thanks to the user of Medium Renemari Padillo, whose tutorial helped us to create our own).

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 whether to run a
// Listen to the messages that begin with ‘I’
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: ‘“Greetings! Welcome to the server!’
});
break;
// Add any command if desired
}
}
});

This code sets up a bot that responds to certain messages. Specifically, anything that starts with a character “ o”, so that if someone writes “Hello!” on your server while the bot is online, it will automatically answer. We define our message as “Greetings! Welcome to the server!”. But you can change them in the code above. Just make sure that the messages are between the single quotes.

Save this file as “bot.js” in your folder of Discord.

Step 8: open the command prompt

Anre el símbolo de sistema en la carpeta Discord

On a PC with Windows, you can easily access the command Prompt by clicking the Windows icon and typing “command Prompt”. When it is open, type “cd” followed by the path to the folder of your files. Where did the test, the command looks like this: “cd Users\Phil”s Desktop\Desktop\DiscordBot“.

You can also go to your folder in Windows and hold the key Shiftwhile clicking with the right button on a blank area of the folder and select Open command window here.

Step 9: use the command prompt to install add-ons to the bot

Debes instalar algunos archivos complementarios para que tu bot funcione

The time came to use Node.js. In the command prompt, with your folder of Discord in the path, type “npm install discord.io winston –save”. This will install automatically in the folder the files you need for your bot of Discord.

Also use the following command line to install additional plugins: npm install https://github.com/woor/discord.io/tarball/gateway_v6

This should give you all the files you need.

Step 10: run the bot

Prueba tu bot
We test our bot with an automated response in English.

That should be all. To run your bot, type “node bot.js” at the command prompt (be sure to follow in your folder of Discord).

Now back to the server of Discord and test your bot by typing “Hello!” or “ I” If everything went correctly, your bot should return the message immediately that codificaste.

Congratulations you know how to create a bot for Discord!

Step 11: find out if your bot has been made by someone else

Discord has a community that shares things for the benefit of all, and that includes the bots. If you want to find out how to create a bot for Discord that perform other functions, you could save time by searching on sites such as discordbots.org and bots.discord.pw, but it is also likely that you will have luck on Google.

Recommendations of the editor


SHARE
RELATED POSTS
Oh Nintendo is for party! ‘Super Smash Bros. Ultimate’ and the Switch raze in sales
Farming Simulator enters the eSports in league of its own
How to get special items in the Pokémon Go

Comments are closed.