Erreur de connexion bot to discord

Par Kirua Zoldik, il y a 5 ans


Javascript NodeJS

Bonjour,

Je rencontre un petit problème avec mon code.
Pourriez-vous m'aider svp ?

Ce que je fais

Je cherche à configurer mon bot, mais déjà à le connecter à discord

const Discord = require('discord.js'); const bot = new Discord.Client(); bot.login('LE TOKEN')

Ce que je veux

Je veux que mon bot se connecte à discord

Ce que j'obtiens

Un joli message d'erreur

(node:16068) UnhandledPromiseRejectionWarning: FetchError: request to https://discord.com/api/v7/gateway/bot failed, reason: unable to verify the first certificate at RequestHandler.execute (C:\Users\Collegien\Desktop\Discord\node_modules\discord.js\src\rest\RequestHandler.js:93:15) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async RequestHandler.push (C:\Users\Collegien\Desktop\Discord\node_modules\discord.js\src\rest\RequestHandler.js:39:14) at async WebSocketManager.connect (C:\Users\Collegien\Desktop\Discord\node_modules\discord.js\src\client\websocket\WebSocketManager.js:138:9) at async Client.login (C:\Users\Collegien\Desktop\Discord\node_modules\discord.js\src\client\Client.js:223:7) (Use `node --trace-warnings ...` to show where the warning was created) (node:16068) 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: 3) (node:16068) [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.

6 réponses

hanako-eo, il y a 5 ans

met a jour discord.js
il faut utiliser la v8 de l'api de discord

hoshiyo, il y a 5 ans
const Discord = require('discord.js'); const client = new Discord.Client(); client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); client.on('message', msg => { if (msg.content === 'ping') { msg.reply('Pong!'); } }); client.login('token');``` //https://discord.js.org/#/ //lis cette doc pour t'aider
Flymeth, il y a 4 ans

Verifie également ta version de node (et mets la à jour si besoin)

popotte, il y a 4 ans

Alors ton erreur est un problème SSL, il faut le renouveller :/

J'ai cherché un peu et apparement tu peux simplement visiter ce site sur le pc qui pose problème:
https://discordapp.com/

Et autoriser le bot si ca demande, mais apparement le site rafraichit le certificat, ensuite retentes ton applis, et il devrait tester le nouveau certificat SSL

manibossofficiel, il y a 4 ans

Merci aussi moi aussi ca maide