mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 13:02:38 +00: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:
parent
4653f88555
commit
3e2d6ccc48
2 changed files with 14 additions and 1 deletions
|
|
@ -37,6 +37,17 @@ class Client extends EventEmitter {
|
|||
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
|
||||
* @type {RESTManager}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ class WebSocketPacketManager {
|
|||
|
||||
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 (BeforeReadyWhitelist.indexOf(packet.t) === -1) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue