src: Cleanup event listeners on WebSocket connections (#3681)

* src: Cleanup event listeners on WebSocket connections
Should prevent #3641 from happening, as well as double connections on a shard

* typings: Forgot to add the method
This commit is contained in:
Vlad Frangu
2020-01-13 20:53:07 +02:00
committed by Amish Shah
parent 45cd58b68c
commit c23cc7a42e
3 changed files with 29 additions and 5 deletions

View File

@@ -245,6 +245,8 @@ class WebSocketManager extends EventEmitter {
});
shard.on(ShardEvents.DESTROYED, () => {
shard._cleanupConnection();
this.debug('Shard was destroyed but no WebSocket connection was present! Reconnecting...', shard);
this.client.emit(Events.SHARD_RECONNECTING, shard.id);