refactor: ES2021 features (#6540)

Co-authored-by: Antonio Román <kyradiscord@gmail.com>
Co-authored-by: Voltrex <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
Rodry
2021-09-03 12:58:01 +01:00
committed by GitHub
parent d81590d566
commit 00bd92a451
35 changed files with 145 additions and 156 deletions

View File

@@ -415,7 +415,7 @@ class WebSocketShard extends EventEmitter {
break;
case Opcodes.RECONNECT:
this.debug('[RECONNECT] Discord asked us to reconnect');
this.destroy({ closeCode: 4000 });
this.destroy({ closeCode: 4_000 });
break;
case Opcodes.INVALID_SESSION:
this.debug(`[INVALID SESSION] Resumable: ${packet.d}.`);
@@ -489,7 +489,7 @@ class WebSocketShard extends EventEmitter {
this.emit(ShardEvents.ALL_READY, this.expectedGuilds);
},
hasGuildsIntent ? 15000 : 0,
hasGuildsIntent ? 15_000 : 0,
).unref();
}
@@ -511,7 +511,7 @@ class WebSocketShard extends EventEmitter {
this.helloTimeout = setTimeout(() => {
this.debug('Did not receive HELLO in time. Destroying and connecting again.');
this.destroy({ reset: true, closeCode: 4009 });
}, 20000).unref();
}, 20_000).unref();
}
/**
@@ -656,7 +656,7 @@ class WebSocketShard extends EventEmitter {
_send(data) {
if (this.connection?.readyState !== WebSocket.OPEN) {
this.debug(`Tried to send packet '${JSON.stringify(data)}' but no WebSocket is available!`);
this.destroy({ closeCode: 4000 });
this.destroy({ closeCode: 4_000 });
return;
}
@@ -692,7 +692,7 @@ class WebSocketShard extends EventEmitter {
* @param {Object} [options={ closeCode: 1000, reset: false, emit: true, log: true }] Options for destroying the shard
* @private
*/
destroy({ closeCode = 1000, reset = false, emit = true, log = true } = {}) {
destroy({ closeCode = 1_000, reset = false, emit = true, log = true } = {}) {
if (log) {
this.debug(`[DESTROY]
Close Code : ${closeCode}