mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
Convert disabledEvents Array to Object (#786)
* Convert disabledEvents Array to Object Increased performance * Commit to please Lord Gawdl3y * Nitpick with chopsticks
This commit is contained in:
committed by
Schuyler Cebulskie
parent
4653f88555
commit
3e2d6ccc48
@@ -37,6 +37,17 @@ class Client extends EventEmitter {
|
|||||||
this.options.shardCount = Number(process.env.SHARD_COUNT);
|
this.options.shardCount = Number(process.env.SHARD_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(this.options.disabledEvents instanceof 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}
|
||||||
|
|||||||
@@ -84,7 +84,9 @@ class WebSocketPacketManager {
|
|||||||
|
|
||||||
this.setSequence(packet.s);
|
this.setSequence(packet.s);
|
||||||
|
|
||||||
if (this.ws.client.options.disabledEvents.includes(packet.t)) return false;
|
if (this.ws.client.options.disabledEvents[packet.t] !== undefined) {
|
||||||
|
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