handle voice connection destroy error
This commit is contained in:
parent
8eff4d919b
commit
9a18499aab
1 changed files with 17 additions and 3 deletions
|
@ -74,13 +74,21 @@ class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
||||||
try {
|
try {
|
||||||
await entersState(this.voiceConnection, VoiceConnectionStatus.Connecting, this.connectionTimeout);
|
await entersState(this.voiceConnection, VoiceConnectionStatus.Connecting, this.connectionTimeout);
|
||||||
} catch {
|
} catch {
|
||||||
this.voiceConnection.destroy();
|
try {
|
||||||
|
this.voiceConnection.destroy();
|
||||||
|
} catch (err) {
|
||||||
|
this.emit("error", err as AudioPlayerError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (this.voiceConnection.rejoinAttempts < 5) {
|
} else if (this.voiceConnection.rejoinAttempts < 5) {
|
||||||
await Util.wait((this.voiceConnection.rejoinAttempts + 1) * 5000);
|
await Util.wait((this.voiceConnection.rejoinAttempts + 1) * 5000);
|
||||||
this.voiceConnection.rejoin();
|
this.voiceConnection.rejoin();
|
||||||
} else {
|
} else {
|
||||||
this.voiceConnection.destroy();
|
try {
|
||||||
|
this.voiceConnection.destroy();
|
||||||
|
} catch (err) {
|
||||||
|
this.emit("error", err as AudioPlayerError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (newState.status === VoiceConnectionStatus.Destroyed) {
|
} else if (newState.status === VoiceConnectionStatus.Destroyed) {
|
||||||
this.end();
|
this.end();
|
||||||
|
@ -89,7 +97,13 @@ class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
||||||
try {
|
try {
|
||||||
await entersState(this.voiceConnection, VoiceConnectionStatus.Ready, this.connectionTimeout);
|
await entersState(this.voiceConnection, VoiceConnectionStatus.Ready, this.connectionTimeout);
|
||||||
} catch {
|
} catch {
|
||||||
if (this.voiceConnection.state.status !== VoiceConnectionStatus.Destroyed) this.voiceConnection.destroy();
|
if (this.voiceConnection.state.status !== VoiceConnectionStatus.Destroyed) {
|
||||||
|
try {
|
||||||
|
this.voiceConnection.destroy();
|
||||||
|
} catch (err) {
|
||||||
|
this.emit("error", err as AudioPlayerError);
|
||||||
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.readyLock = false;
|
this.readyLock = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue