Skip to content

Commit

Permalink
fix(QueueManager): fix PlayingError when stoping the queue
Browse files Browse the repository at this point in the history
 while creating the stream
  • Loading branch information
skick1234 committed Dec 27, 2022
1 parent 73b2743 commit 0870a69
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/core/manager/QueueManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,10 @@ export class QueueManager extends GuildIdManager<Queue> {
*/
async playSong(queue: Queue): Promise<boolean> {
if (!queue) return true;
if (!queue.songs.length) {
if (queue.stopped || !queue.songs.length) {
queue.stop();
return true;
}
if (queue.stopped) return false;
try {
const song = queue.songs[0];
const { url, source, formats, streamURL, isLive } = song;
Expand All @@ -183,11 +182,14 @@ export class QueueManager extends GuildIdManager<Queue> {
}
}
}
if (queue.stopped || !queue.songs.length) {
queue.stop();
return true;
}
const stream = this.createStream(queue);
queue.voice.play(stream);
song.streamURL = stream.url;
if (queue.stopped) queue.stop();
else if (queue.paused) queue.voice.pause();
if (queue.paused) queue.voice.pause();
return false;
} catch (e: any) {
this.#handlePlayingError(queue, e);
Expand All @@ -196,9 +198,6 @@ export class QueueManager extends GuildIdManager<Queue> {
}
/**
* Whether or not emit playSong event
* @param {Queue} queue Queue
* @private
* @returns {boolean}
*/
#emitPlaySong(queue: Queue): boolean {
return (
Expand Down

0 comments on commit 0870a69

Please sign in to comment.