Only add event listeners once

See #372
This commit is contained in:
Max Isom 2021-10-03 12:59:26 -04:00
parent 20a030e307
commit 1ddd19dbb9
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880

View file

@ -441,14 +441,18 @@ export default class {
return;
}
if (this.voiceConnection.listeners('disconnect').length === 0) {
this.voiceConnection.on('disconnect', this.onVoiceConnectionDisconnect.bind(this));
}
if (!this.dispatcher) {
return;
}
if (this.dispatcher.listeners('speaking').length === 0) {
this.dispatcher.on('speaking', this.onVoiceConnectionSpeaking.bind(this));
}
}
private onVoiceConnectionDisconnect(): void {
this.disconnect(false);