2

I'm working with a Discord bot using the node.js module discord.js.

Recently an error appears on start up (when the bot attempts to login) when using the work wifi which I believe was configured in some way that caused it to break.

(node:104) UnhandledPromiseRejectionWarning: FetchError: request to https://discordapp.com/api/v7/gateway/bot failed, reason: read ECONNRESET
    at RequestHandler.execute (C:\Users\user\Desktop\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:106:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:104) 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(). (rejection id: 1)
(node:104) [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.

The error is thrown from the file RequestHandler.js which uses the APIRequest method make from the file APIRequest.js which returns the result from the function fetch from the file index.js which returns a rejected promise.

The variable req is the ClientRequest (from the module _http_client) returned from the method request from the https module.

If I comment out the req.on('error', function (err) { ... }); then I get the following error:

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)
Emitted 'error' event at:
    at TLSSocket.socketErrorListener (_http_client.js:391:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Which I believe to be thrown from here but it's an internal module of Node.js (internal/stream_base_commons.js) which I can't edit and continue tracking deeper. Would have to edit and recompile which is not something I know how to do.

When I go to https://discordapp.com/api/v7/gateway/bot I get the response:

{"code": 0, "message": "401: Unauthorized"}

I need help understanding the exact cause of the original error and if there's any workaround to continue running the bot.

user7393973
  • 2,270
  • 1
  • 20
  • 58

1 Answers1

0

I had the same problem, I just checked the bot login token and it was outdated. Try generating a new bot token on the Discord developer portal !

Toro20067
  • 1
  • 1