Connexion
S'inscrire
Actualités
Quoi de neuf
Activités générales
Auteurs
Forums
Nouveaux messages
Rechercher un forum
Quoi de neuf
Nouveaux messages
Nouveaux messages de profil
Activités générales
Membres
Membres inscrits
Visiteurs actuels
Nouveaux messages de profil
Rechercher dans les messages des profils
Teams
Créé ton équipe
Quoi de neuf ?
Nouveaux messages
Rechercher un forum
Menu
Connexion
S'inscrire
Install the app
Install
Forums
Forums généraux
Informatique
Développement
I - Coder un bot discord
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Vous utilisez un navigateur non à jour ou ancien. Il ne peut pas afficher ce site ou d'autres sites correctement.
Vous devez le mettre à jour ou utiliser un
navigateur alternatif
.
Répondre à la discussion
Message
<blockquote data-quote="deleted732323" data-source="post: 7062476"><p style="text-align: center"></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Salut à tous <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite400" alt="::):" title="Smile ::):" loading="lazy" data-shortname="::):" /> je commence ma série de : "Comment coder son propre bot discord".</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Il tournera avec node.JS ainsi que la librairie de discord.JS, avec un quelques autres modules.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p style="text-align: center"><span style="font-family: 'Didact Gothic'"><span style="font-size: 18px">[FA]fa-diamond[/FA] PRÉ-REQUIS</span></span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">- NODE.JS</span></p><p><span style="font-family: 'Didact Gothic'">- Editeur de code, j'utilise Visual Studio Code.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p style="text-align: center"><span style="font-family: 'Exo'">[FA]fa-toggle-on[/FA] DÉMARRAGE</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">On va initialiser le projet node.JS, pour cela il faut vous rendre sur le CMD, dans le répertoire où vous voulez que votre projet soit installé.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Pour cela, on va utiliser la commande</span></p><p><span style="font-family: 'Didact Gothic'">[CODE]npm init[/CODE]</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">NOTE : La plus part des commandes de node commence par npm <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite355" alt=":)" title=":) :)" loading="lazy" data-shortname=":)" /></span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Appuyez sur la touche ENTRÉE à chaque question.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p style="text-align: center"><span style="font-family: 'Didact Gothic'"><img src="http://zupimages.net/up/17/07/gw3i.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></p> <p style="text-align: center"><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Vous pouvez voir que cette commande a crée seulement le fichier package.JSON. Ce qui nous intéresse dans celui-ci est la ligne de "main", ce fichier, qui est de base "index.JS", c'est lui qui va être exécuté lors du lancement du propre. C'est le coeur du Bot.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Nous allons le créer, on fait un petit 'Hello World !' pour voir si tout fonctionne bien</span></p><p><span style="font-family: 'Didact Gothic'">[CODE]console.log('Hello World !');[/CODE]</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Et nous l'exécutons avec un [CODE]node . [/CODE] </span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><strong><span style="color: #b30059"><span style="font-family: 'Didact Gothic'">[FA]fa-warning[/FA] On va voir que cette commande va changer à l'avenir</span></span></strong></p><p></p><p style="text-align: center"><span style="font-family: 'Didact Gothic'"><img src="http://zupimages.net/up/17/07/iho9.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </span></p> <p style="text-align: center"><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">[FA]fa-code[/FA] Création de la base</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Maintenant que nous avons bien démarrer le projet, nous allons importer discord.JS, et inutile de télécharger/installer quoi que ce soit ! Node va s'en charger pour nous.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Pour cela, nous allons demander à notre cher petit node d'installer discord.js, et la sauvegarder</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">[CODE]npm install discord.js --save[/CODE]</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p style="text-align: center"><span style="font-family: 'Didact Gothic'"><img src="http://zupimages.net/up/17/07/95mb.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </span></p> <p style="text-align: center"><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Maintenant, c'est très facile d'importer la libraire Discord dans notre code.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">On va créer une constante Discord, et elle va avoir besoin de discord.js</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">[CODE]const Discord = require('discord.js');[/CODE]</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Ainsi que notre constante bot dont la fonction va être dans la librairie nommée Discord.Client(); ! Pas vraiment besoin d'expliquer cette fonction hein. </span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">[CODE]const bot = new Discord.Client();[/CODE]</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Ensuite, on va dire au bot de ce login, avec un bot.login</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">[CODE]bot.login('TOKEN');[/CODE]</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Vous allez dire "ON A PAS DE TOKEN !", eh bien on va voir sa dans le prochain chapitre.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p style="text-align: center"><span style="font-family: 'Didact Gothic'"><span style="font-size: 18px">[FA]fa-cog[/FA] Création du bot</span></span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Pour créer le profil de notre bot, on va se rendre sur la <a href="https://discordapp.com/developers/docs/intro" target="_blank">page dédiée au développeur Discord !</a></span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">On va aller dans My Apps, puis créons une nouvelle application, perso je vais l’appeler <strong>TCHOIN</strong> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite375" alt=":trollface:" title="Trollface :trollface:" loading="lazy" data-shortname=":trollface:" />, après vous faites comme vous voulez, vous lui donner une description ainsi qu'un avatar.</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p style="text-align: center"><span style="font-family: 'Didact Gothic'"><img src="http://zupimages.net/up/17/07/ejua.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </span></p> <p style="text-align: center"><span style="font-family: 'Didact Gothic'"></span></p> <p style="text-align: center"><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Et vous allez le déclarer comme un BOT. </span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p style="text-align: center"><span style="font-family: 'Didact Gothic'"><img src="http://zupimages.net/up/17/07/igfp.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </span></p> <p style="text-align: center"><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Maintenant, notre bot existe, et pour avoir le token, il vous suffit de le cliquer sur TOKEN, et n'oubliez pas aussi de dire que votre bot est public, on verra pourquoi par la suite <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite351" alt=";)" title="Clin d'oeil ;)" loading="lazy" data-shortname=";)" /></span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p style="text-align: center"><span style="font-family: 'Didact Gothic'"><img src="http://zupimages.net/up/17/07/7j93.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </span></p> <p style="text-align: center"><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'">Ce sera tout pour cette première partie, je vous retrouve très vite pour la deuxième !</span></p><p><span style="font-family: 'Didact Gothic'"></span></p><p><span style="font-family: 'Didact Gothic'"><a href="https://reality-gaming.fr/threads/ii-coder-un-bot-discord.591393/" target="_blank">Deuxième partie dispo !</a></span></p><p><span style="font-family: 'Didact Gothic'"></span></p></blockquote><p></p>
[QUOTE="deleted732323, post: 7062476"] [CENTER][/CENTER] [FONT=Didact Gothic] Salut à tous ::): je commence ma série de : "Comment coder son propre bot discord". Il tournera avec node.JS ainsi que la librairie de discord.JS, avec un quelques autres modules. [/FONT] [CENTER][FONT=Didact Gothic][SIZE=5][FA]fa-diamond[/FA] PRÉ-REQUIS[/SIZE][/FONT][/CENTER] [FONT=Didact Gothic] - NODE.JS - Editeur de code, j'utilise Visual Studio Code. [/FONT] [CENTER][FONT=Exo][FA]fa-toggle-on[/FA] DÉMARRAGE[/FONT][/CENTER] [FONT=Didact Gothic] On va initialiser le projet node.JS, pour cela il faut vous rendre sur le CMD, dans le répertoire où vous voulez que votre projet soit installé. Pour cela, on va utiliser la commande [CODE]npm init[/CODE] NOTE : La plus part des commandes de node commence par npm :) Appuyez sur la touche ENTRÉE à chaque question. [/FONT] [CENTER][FONT=Didact Gothic][IMG]http://zupimages.net/up/17/07/gw3i.png[/IMG] [/FONT][/CENTER] [FONT=Didact Gothic]Vous pouvez voir que cette commande a crée seulement le fichier package.JSON. Ce qui nous intéresse dans celui-ci est la ligne de "main", ce fichier, qui est de base "index.JS", c'est lui qui va être exécuté lors du lancement du propre. C'est le coeur du Bot. Nous allons le créer, on fait un petit 'Hello World !' pour voir si tout fonctionne bien [CODE]console.log('Hello World !');[/CODE] Et nous l'exécutons avec un [CODE]node . [/CODE] [/FONT] [B][COLOR=#b30059][FONT=Didact Gothic][FA]fa-warning[/FA] On va voir que cette commande va changer à l'avenir[/FONT][/COLOR][/B] [CENTER][FONT=Didact Gothic][IMG]http://zupimages.net/up/17/07/iho9.png[/IMG] [/FONT][/CENTER] [FONT=Didact Gothic] [FA]fa-code[/FA] Création de la base Maintenant que nous avons bien démarrer le projet, nous allons importer discord.JS, et inutile de télécharger/installer quoi que ce soit ! Node va s'en charger pour nous. Pour cela, nous allons demander à notre cher petit node d'installer discord.js, et la sauvegarder [CODE]npm install discord.js --save[/CODE] [/FONT] [CENTER][FONT=Didact Gothic][IMG]http://zupimages.net/up/17/07/95mb.png[/IMG] [/FONT][/CENTER] [FONT=Didact Gothic]Maintenant, c'est très facile d'importer la libraire Discord dans notre code. On va créer une constante Discord, et elle va avoir besoin de discord.js [CODE]const Discord = require('discord.js');[/CODE] Ainsi que notre constante bot dont la fonction va être dans la librairie nommée Discord.Client(); ! Pas vraiment besoin d'expliquer cette fonction hein. [CODE]const bot = new Discord.Client();[/CODE] Ensuite, on va dire au bot de ce login, avec un bot.login [CODE]bot.login('TOKEN');[/CODE] Vous allez dire "ON A PAS DE TOKEN !", eh bien on va voir sa dans le prochain chapitre. [/FONT] [CENTER][FONT=Didact Gothic][SIZE=5][FA]fa-cog[/FA] Création du bot[/SIZE][/FONT][/CENTER] [FONT=Didact Gothic] Pour créer le profil de notre bot, on va se rendre sur la [URL='https://discordapp.com/developers/docs/intro']page dédiée au développeur Discord ![/URL] On va aller dans My Apps, puis créons une nouvelle application, perso je vais l’appeler [B]TCHOIN[/B] :trollface:, après vous faites comme vous voulez, vous lui donner une description ainsi qu'un avatar. [/FONT] [CENTER][FONT=Didact Gothic][IMG]http://zupimages.net/up/17/07/ejua.png[/IMG] [/FONT][/CENTER] [FONT=Didact Gothic]Et vous allez le déclarer comme un BOT. [/FONT] [CENTER][FONT=Didact Gothic][IMG]http://zupimages.net/up/17/07/igfp.png[/IMG] [/FONT][/CENTER] [FONT=Didact Gothic]Maintenant, notre bot existe, et pour avoir le token, il vous suffit de le cliquer sur TOKEN, et n'oubliez pas aussi de dire que votre bot est public, on verra pourquoi par la suite ;) [/FONT] [CENTER][FONT=Didact Gothic][IMG]http://zupimages.net/up/17/07/7j93.png[/IMG] [/FONT][/CENTER] [FONT=Didact Gothic]Ce sera tout pour cette première partie, je vous retrouve très vite pour la deuxième ! [URL='https://reality-gaming.fr/threads/ii-coder-un-bot-discord.591393/']Deuxième partie dispo ![/URL] [/FONT] [/QUOTE]
Insérer les citations…
Vérification
Publier la réponse
Forums
Forums généraux
Informatique
Développement
I - Coder un bot discord
Ce site utilise des cookies. En continuant à utiliser ce site, vous acceptez l'utilisation des cookies.
Acceptez
En savoir plus.…
Haut