Skip to content

Commit

Permalink
fix(queue): stopping multiple times
Browse files Browse the repository at this point in the history
🐛 Fixed bug when queue stop function executed after already called
  • Loading branch information
eritislami committed Sep 5, 2022
1 parent 68bea9b commit 16d0160
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions structs/MusicQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export class MusicQueue {
} else {
this.connection.destroy();
}
} else if (newState.status === VoiceConnectionStatus.Destroyed) {
// this.stop();
} else if (
!this.readyLock &&
(newState.status === VoiceConnectionStatus.Connecting || newState.status === VoiceConnectionStatus.Signalling)
Expand All @@ -70,7 +68,11 @@ export class MusicQueue {
try {
await entersState(this.connection, VoiceConnectionStatus.Ready, 20_000);
} catch {
if (this.connection.state.status !== VoiceConnectionStatus.Destroyed) this.connection.destroy();
if (this.connection.state.status !== VoiceConnectionStatus.Destroyed) {
try {
this.connection.destroy();
} catch {}
}
} finally {
this.readyLock = false;
}
Expand All @@ -85,7 +87,7 @@ export class MusicQueue {
this.songs.shift();
}

this.processQueue();
if (this.songs.length) this.processQueue();
} else if (oldState.status === AudioPlayerStatus.Buffering && newState.status === AudioPlayerStatus.Playing) {
this.sendPlayingMessage(newState);
}
Expand Down

0 comments on commit 16d0160

Please sign in to comment.