Merge pull request #373 from codetheweb/bugfix/only-add-listeners-once

This commit is contained in:
Max Isom 2021-11-17 16:23:31 -05:00 committed by GitHub
commit 7b2401ff19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -452,14 +452,18 @@ export default class {
return;
}
if (this.voiceConnection.listeners(VoiceConnectionStatus.Disconnected).length === 0) {
this.voiceConnection.on(VoiceConnectionStatus.Disconnected, this.onVoiceConnectionDisconnect.bind(this));
}
if (!this.audioPlayer) {
return;
}
if (this.audioPlayer.listeners('stateChange').length === 0) {
this.audioPlayer.on('stateChange', this.onAudioPlayerStateChange.bind(this));
}
}
private onVoiceConnectionDisconnect(): void {
this.disconnect();