mirror of
https://github.com/danbulant/discord.js
synced 2026-07-05 19:20:42 +00:00
Add support to recognise 4004 codes and throw an error
This commit is contained in:
parent
84a4755f53
commit
c8be80abd7
3 changed files with 7 additions and 3 deletions
File diff suppressed because one or more lines are too long
|
|
@ -59,7 +59,7 @@ class WebSocketManager {
|
||||||
*/
|
*/
|
||||||
this.ws = new WebSocket(gateway);
|
this.ws = new WebSocket(gateway);
|
||||||
this.ws.onopen = () => this.eventOpen();
|
this.ws.onopen = () => this.eventOpen();
|
||||||
this.ws.onclose = () => this.eventClose();
|
this.ws.onclose = (d) => this.eventClose(d);
|
||||||
this.ws.onmessage = (e) => this.eventMessage(e);
|
this.ws.onmessage = (e) => this.eventMessage(e);
|
||||||
this.ws.onerror = (e) => this.eventError(e);
|
this.ws.onerror = (e) => this.eventError(e);
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +126,10 @@ class WebSocketManager {
|
||||||
* Run whenever the connection to the gateway is closed, it will try to reconnect the client.
|
* Run whenever the connection to the gateway is closed, it will try to reconnect the client.
|
||||||
* @returns {null}
|
* @returns {null}
|
||||||
*/
|
*/
|
||||||
eventClose() {
|
eventClose(event) {
|
||||||
|
if (event.code === 4004) {
|
||||||
|
throw Constants.Errors.BAD_LOGIN;
|
||||||
|
}
|
||||||
if (!this.reconnecting) {
|
if (!this.reconnecting) {
|
||||||
this.tryReconnect();
|
this.tryReconnect();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ exports.Errors = {
|
||||||
TOOK_TOO_LONG: new Error('something took too long to do'),
|
TOOK_TOO_LONG: new Error('something took too long to do'),
|
||||||
NOT_A_PERMISSION: new Error('that is not a valid permission number'),
|
NOT_A_PERMISSION: new Error('that is not a valid permission number'),
|
||||||
INVALID_RATE_LIMIT_METHOD: new Error('unknown rate limiting method'),
|
INVALID_RATE_LIMIT_METHOD: new Error('unknown rate limiting method'),
|
||||||
|
BAD_LOGIN: new Error('incorrect login details were provided'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const API = 'https://discordapp.com/api';
|
const API = 'https://discordapp.com/api';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue