refactor: add some more consistency (#3842)

* cleanup(StreamDispatcher): remove old 'end' event

* fix(StreamDispatcher): only listen to finish event once

* refactor(VoiceWebSocket): use `connection.client` in favour of `connection.voiceManager.client`

* fix(VoiceWebSocket): use `client.clearInterval` in favour of `clearInterval`

* refactor: destructure EventEmitter

* refactor: destructure EventEmitter from events

* refactor: use EventEmitter.off in favour of EventEmitter.removeListener

* style: order typings alphabetically

* oops

* fix indent

* style: alphabetically organize imports

* style: remove extra line

* Revert "style: remove extra line"

This reverts commit 96e182ed69.

* Revert "style: alphabetically organize imports"

This reverts commit 02aee9b06d.

* Revert "refactor: destructure EventEmitter from events"

This reverts commit 9953b4d267.

* Revert "refactor: destructure EventEmitter"

This reverts commit 930d7751ab.

* Revert "fix(StreamDispatcher): only listen to finish event once"

This reverts commit 485a6430a8.

* refactor: use .removeListener instead of .off
This commit is contained in:
Sugden
2020-02-28 17:02:51 +00:00
committed by GitHub
parent df88729c44
commit 1af1e0cbb8
4 changed files with 243 additions and 243 deletions

View File

@@ -35,7 +35,7 @@ class VoiceWebSocket extends EventEmitter {
* @readonly
*/
get client() {
return this.connection.voiceManager.client;
return this.connection.client;
}
shutdown() {
@@ -232,7 +232,7 @@ class VoiceWebSocket extends EventEmitter {
* @event VoiceWebSocket#warn
*/
this.emit('warn', 'A voice heartbeat interval is being overwritten');
clearInterval(this.heartbeatInterval);
this.client.clearInterval(this.heartbeatInterval);
}
this.heartbeatInterval = this.client.setInterval(this.sendHeartbeat.bind(this), interval);
}
@@ -245,7 +245,7 @@ class VoiceWebSocket extends EventEmitter {
this.emit('warn', 'Tried to clear a heartbeat interval that does not exist');
return;
}
clearInterval(this.heartbeatInterval);
this.client.clearInterval(this.heartbeatInterval);
this.heartbeatInterval = null;
}

View File

@@ -175,11 +175,11 @@ class WebSocketShard extends EventEmitter {
return new Promise((resolve, reject) => {
const cleanup = () => {
this.off(ShardEvents.CLOSE, onClose);
this.off(ShardEvents.READY, onReady);
this.off(ShardEvents.RESUMED, onResumed);
this.off(ShardEvents.INVALID_SESSION, onInvalidOrDestroyed);
this.off(ShardEvents.DESTROYED, onInvalidOrDestroyed);
this.removeListener(ShardEvents.CLOSE, onClose);
this.removeListener(ShardEvents.READY, onReady);
this.removeListener(ShardEvents.RESUMED, onResumed);
this.removeListener(ShardEvents.INVALID_SESSION, onInvalidOrDestroyed);
this.removeListener(ShardEvents.DESTROYED, onInvalidOrDestroyed);
};
const onReady = () => {

View File

@@ -230,8 +230,8 @@ class Collector extends EventEmitter {
// eslint-disable-next-line no-await-in-loop
await new Promise(resolve => {
const tick = () => {
this.off('collect', tick);
this.off('end', tick);
this.removeListener('collect', tick);
this.removeListener('end', tick);
return resolve();
};
this.on('collect', tick);
@@ -240,7 +240,7 @@ class Collector extends EventEmitter {
}
}
} finally {
this.off('collect', onCollect);
this.removeListener('collect', onCollect);
}
}