mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
Reorganise disabledEvents stuff
This commit is contained in:
@@ -41,13 +41,6 @@ class Client extends EventEmitter {
|
|||||||
throw new TypeError('The disabledEvents client option must be an array.');
|
throw new TypeError('The disabledEvents client option must be an array.');
|
||||||
}
|
}
|
||||||
|
|
||||||
let disabledEvents = {};
|
|
||||||
for (const event in this.options.disabledEvents) {
|
|
||||||
disabledEvents[event] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.options.disabledEvents = disabledEvents;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The REST manager of the client
|
* The REST manager of the client
|
||||||
* @type {RESTManager}
|
* @type {RESTManager}
|
||||||
|
|||||||
@@ -59,6 +59,13 @@ class WebSocketManager extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object with keys that are websocket event names that should be ignored
|
||||||
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
this.disabledEvents = {};
|
||||||
|
for (const event in client.options.disabledEvents) this.disabledEvents[event] = true;
|
||||||
|
|
||||||
this.first = true;
|
this.first = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,9 +76,7 @@ class WebSocketManager extends EventEmitter {
|
|||||||
_connect(gateway) {
|
_connect(gateway) {
|
||||||
this.client.emit('debug', `Connecting to gateway ${gateway}`);
|
this.client.emit('debug', `Connecting to gateway ${gateway}`);
|
||||||
this.normalReady = false;
|
this.normalReady = false;
|
||||||
if (this.status !== Constants.Status.RECONNECTING) {
|
if (this.status !== Constants.Status.RECONNECTING) this.status = Constants.Status.CONNECTING;
|
||||||
this.status = Constants.Status.CONNECTING;
|
|
||||||
}
|
|
||||||
this.ws = new WebSocket(gateway);
|
this.ws = new WebSocket(gateway);
|
||||||
this.ws.onopen = () => this.eventOpen();
|
this.ws.onopen = () => this.eventOpen();
|
||||||
this.ws.onclose = (d) => this.eventClose(d);
|
this.ws.onclose = (d) => this.eventClose(d);
|
||||||
|
|||||||
@@ -84,9 +84,7 @@ class WebSocketPacketManager {
|
|||||||
|
|
||||||
this.setSequence(packet.s);
|
this.setSequence(packet.s);
|
||||||
|
|
||||||
if (this.ws.client.options.disabledEvents[packet.t] !== undefined) {
|
if (this.ws.disabledEvents[packet.t] !== undefined) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.ws.status !== Constants.Status.READY) {
|
if (this.ws.status !== Constants.Status.READY) {
|
||||||
if (BeforeReadyWhitelist.indexOf(packet.t) === -1) {
|
if (BeforeReadyWhitelist.indexOf(packet.t) === -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user