Comment Créer un Bot Discord ?

For many years, Discord has shown that it strives to continue to improve in order to offer the best possible experience to its users, thus becoming a platform that is no longer only used by players. It is nowadays one of the most used platforms for messages, video apps and continuous broadcasting among friends.

The Discord functionalities are being developed as the development team improves the platform, but bots are undoubtedly one of the most particular assets that can be found in this plate-form.

comment believe a discord bot

Avec un Discord bot, les users can do almost anything they want with a JavaScript code.. But if you have no knowledge of programming, don't worry. In this article, we will guide you step by step so that you can create your own Discord bot even if you are not a programming expert.

Table
  1. Steps to follow to create a bot on Discord
    1. 1. - Download Node.js and prepare your Discord account.
    2. 2.- Créez votre propre bot
    3. 3.- Obtain the authorization jeton for your bot
    4. 4.- Send your bot to your service provider
    5. 5.- Create a "bot" file on your computer
    6. 6.- Open the text editor to create your bot files
  2. {
  3. {
    1. 7.- Define your bot code
    2. Début du code
    3. End of code
    4. 8.- Open the order invitation on your computer and navigate to the Discord folder.
    5. 9.- Use the command prompt to install your bot
    6. 10.- Faire fonctionner le bot

Steps to follow to create a bot on Discord

1. - Download Node.js and prepare your Discord account.

Node.js allows you to run JavaScript for free because it is an open source program, which is absolutely necessary for your bot to work. You can easily download it from the page of nodejs.org (ici) and you must install it before starting the rest of the process.

As you can imagine, you will also need a Discord account. and your own server to test your bot. If you don't always have a Discord account for any reason, you can easily do it from the discord.com page. If you already have an account, all you need to do is to connect to your account and to open the server where you want to give life to your bot.

You will also need a program such as Notepad++ in Windows to be able to work more comfortably and efficiently with your bot code.

2.- Créez votre propre bot

You must now create an "app" on Discord to make your bot work. This can be done very simply, because the process is not at all complex. Here, the main purpose is to obtain a "jeton d'autorisation". so that Discord can recognize the code and add it to your bot on your servers.

believe-votre-bot-dans-discord

To do this, you must start by clicking on the following link discordapp.com/developers/applications/me (ici). You must be logged in to your account to be able to directly access the parameters of your candidate list. You only need to select New application (New App) pour commencer.

You must give a name to your bot and then you must choose the option Enregistrer les modifications.

For the next step, you have to go to the right menu and select Bot. When you view the new menu, select the option Add a bot under the option Build a bot. If

You have only one request (the one we have just made), it will be automatically selected. However, you must select it.

3.- Obtain the authorization jeton for your bot

Dans la case App Bot user, vous devez chercher le mot Token : Cliquez pour révéler. Once you have clicked here, you will see a line of text. This text will be the authorization jeton of your bot, which will allow you to send the code.

obtain a discord bot token authorization

It is very important that you do not share this jeton with anyone, because the jeton allows anyone who owns it to create a code for the bot, which means that anyone else who owns it will have control of your bot.

If you think your jeton has been compromised, you can generate a new one very easily. In fact, for security reasons, it is recommended that a different token be created each month in selecting the option Generate a new token. After you have done this, you will have your new jeton in a few seconds.

4.- Send your bot to your service provider

You must now go to the indicated location "App Details" and find your phone number client, which is a rather long number. Copy this number and add it to the following URL by replacing the part that says CLIENTID :

send the bot to the discord server

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

Don't forget to delete the part that indicates "CLIENTID" and to enter your real customer number that you have obtained through Discord.

Once you have made this change, copy the URL that already has your client number in your browser to enter the page. This will link you to the Discord page so that you can send your bot.

You will know that everything has been successful if the page sends you to your application or to your service provider. The screen will tell you that a bot has entered the page and you can now see it in the menu on the right.

5.- Create a "bot" file on your computer

After completing the above steps, it is also strongly recommended to create a file on your computer, which is a very easy way to replace the files in your bot.

create a discord bot file on your computer

Il suffit de l'appeler "MyBot" ou "DiscordBot" so as not to forget its contents.

6.- Open the text editor to create your bot files

You can now create three files in the text editor of your choice (you can use the one we recommend above).

editeur-de-texte-discord-bot

In the first file, you must copy this code:

{

token" : "Your Bot Token" : "Your Bot Token".

}

In this code, you must replace the text "Your Bot Token" with the jeton that you generated during the previous steps for your bot. Make sure that the jeton is located inside the keys. Now register the file in the folder you have created for your Discord bot. The file must be named auth.json.

It is very important not to pas enregistrer le fichier en . txt, mais in . json. Now create a second file and add the following code:

{

"nom" : "greeter-bot",

"version" : "1.0.0",

"description" : "Mon premier bot de discord", "main" : "bot.js."

"auteur". : "Votre nom", "dépendances" : {}

}

Cette fois, vous devrez remplacer "Votre nom" by your name, and you will also be able to modify the part "description" by adjusting what you want on your bot. This may be useful to remind you what your bot is supposed to do.

Enregistrez ce fichier sous le nom package.json in the dossier we created at the previous stage.

7.- Define your bot code

We must also create a file, which is the most important since it will be responsible for monitoring the behavior of your bot.

define-le-code-du-bot-discord

In order for you to really control your bot, you must be familiar with JavaScript, but if you are completely new to programming and you just want to do something, you can copy and paste the following code to make a simple bot which can welcome people to your service.

Début du code

var Discord = require('discord.io') ; var logger = require('winston') ; var auth = require('./auth.json') ;

// Configure the parameters of the recorder

logger.remove(logger.transports.Console) ; logger.add(new logger.transports.Console, { coloriser : vrai

}) ;

logger.level = "debug" ;

// Initialiser le bot de discord var bot = nouveau Discord.Client({

token : auth.token autorun : vrai

}) ;

bot.on('ready', function (evt) { logger.info("Connecté") ; logger.info('Connecté sous : ') ; logger.info(bot.username + ' - (' + bot.id + ')') ;

}) ;

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

// Our bot must know if it is going to issue a command.

// Il écoutera les messages qui commenceront par "!` if (message.substring(0, 1) == '!') {

var args = message.substring(1). split(' ') ; var cmd = args [0] ;

args = args.splice(1) ; switch(cmd) {

// !ping cas "ping" :

bot.sendMessage({ à : channelID,

message : "Pong !

}) ;

pause ;

// Il suffit d'ajouter des commandes de cas si vous voulez....

}

}

}) ;

End of code

As mentioned above, this code allows your bot to respond to certain messages, especially those beginning with a character. "!".

That is to say that we program a bot to respond to the command "!intro"If someone writes this on the server while the button is down. The button will respond with a programmed message.

In the code we have just shared, you can see that the message is defined as follows "Salutations, bienvenue sur le serveur !". You can change this message to the greetings you want. Please make sure that the quotations remain intact.

Enregistrez ce fichier sous le nom bot.js in the Discord file that we have created.

8.- Open the order invitation on your computer and navigate to the Discord folder.

In Windows, you can open the command prompt or the console very easily, just click on Open and start tapping. "Invite de commande"then select it in the results that appear.

Once it is open, cover it with "cd" Follow the path to your file. You can view it very easily by navigating in the file and keeping the "Maj" button on top by right clicking on a green area of the file, then you can select the option "Ouvrir l'invite de commande ici". ou "Ouvrir PowerShell ici", according to the console you use.

9.- Use the command prompt to install your bot

You must now use Node.js. At the order prompt, with the access key to your bot's folder, enter the following: "npm install discord.io winston -save."

installer-des-salles-de-bot-discord

This will automatically install the files found in the folder we created for the Discord bot later.

You can also use the following command line to install some additional dependencies:

https://github.com/woor/discord.io/tarball/gateway_v6

This should provide you with all the files you need.

10.- Faire fonctionner le bot

This should be the case and now your bot should be working normally. To try to remove your bot, please "node bot.js" à l'invite de commande (be sure to continue to navigate in the path of your Discord file".

lancer-le-bot-discord

Return to your Discord server and try to test your bot by tapping it. "!intro" ou simplement "!" suivi de n'importe quel message qui se trouve dans le fichier "bot.js".

If everything went well, you will now receive a response message from your bot.

Don't forget that Discord has a large community of users who are constantly creating new things, including bots. You can therefore create many bots created by other users.. If you intend to use them, simply make sure you give them the recognition they deserve.

Subir

This website uses cookies to ensure you have a better experience when browsing the site. More information

en_USEnglish