2022-03-08T19:04:36.004Z listening on *:8081
/var/www/virtual/tenfour/html/~7jam/node_modules/discord.js/src/rest/RequestHandler.js:356
throw new HTTPError(res.statusText, res.constructor.name, res.status, request);
^
Response: Service Unavailable
at RequestHandler.execute (/var/www/virtual/tenfour/html/~7jam/node_modules/discord.js/src/rest/RequestHandler.js:356:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/var/www/virtual/tenfour/html/~7jam/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
at async WebSocketManager.connect (/var/www/virtual/tenfour/html/~7jam/node_modules/discord.js/src/client/websocket/WebSocketManager.js:133:9)
at async Client.login (/var/www/virtual/tenfour/html/~7jam/node_modules/discord.js/src/client/Client.js:245:7) {
code: 503,
method: 'get',
path: '/gateway/bot',
requestData: { json: undefined, files: [] }
}
Here, the discord server is down ("Response: Service Unavailable") and throws an exception.
our code, this.client.login(gConfig.discord_bot_token), while wrapped in a try/catch, is async and returns a Promise which I'm not handling exceptions on it.
fix:
this.client.login(gConfig.discord_bot_token)
.catch(e => {
console.log(`Discord unable to log in ${e}`);
});
The output of
node index
is:Here, the discord server is down ("Response: Service Unavailable") and throws an exception.
our code,
this.client.login(gConfig.discord_bot_token)
, while wrapped in a try/catch, is async and returns aPromise
which I'm not handling exceptions on it.fix: