Erreur lors du lancement d'un bot discord

gui_geekmin08 -  
 Bob -
Bonjour !

Je suis actuellement en train de faire un bot discord en Java-Script.
Mais j'ai un problème, voici le code d'erreur : (node:12588) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (c:\Users\verom\Desktop\shop team\node_modules\discord.js\src\client\websocket\WebSocketManager.js:135:26)
at Client.login (c:\Users\verom\Desktop\shop team\node_modules\discord.js\src\client\Client.js:221:21)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
warning.js:32
(node:12588) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode) (rejection id: 1)
warning.js:32
(node:12588) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Mais personnellement je ne comprend pas très bien le problème.
Merci beaucoup d'avoir pris le temps de lire mon message.
J'attend avec patience de l'aide.
Cordialement gui_geekmin08.

1 réponse

  1. Alvin1614 Messages postés 115 Statut Membre 4
     
    Bonjour, c'est simple !

    Les 3/4 de ce code d'erreur ne nous servent à rien, il faut juste regarder ça :
    Error [TOKEN_INVALID]
    .

    Cela signifie que le token inséré dans ton bot est invalide. Il faut donc que tu insères le bon.

    Pour trouver ton token, va là :


    Ensuite, au début de ton code de bot, tu mets ça :
    require("dotenv").config();
    const Discord = require("discord.js");
    const client = new Discord.Client();
    client.login(process.env.DISCORD_TOKEN);
    client.on("ready", () => {
    console.log(`Connexion réussie avec ${client.user.tag}!`);

    });


    Tu n'as qu'à créer un fichier appelé ".env" dans le même dossier que le fichier principal de ton bot. Ensuite, dedans, tu mets cette ligne :
    DISCORD_TOKEN=LETOKENDUBOT


    Si à la fin de ton fichier tu avais mis quelque chose comme :
    client.login("TOKEN DE TON BOT");

    tu supprimes cette ligne.

    Cordialement,
    -1
    1. Bob
       

      Bonjour !

      J'ai moi même fait se qui vous avez écrit mais cela ne fonctionne tjr pas, token invalide 

      0