Skip to content

Commit

Permalink
fix(queue): properly cancel timeout after stop used
Browse files Browse the repository at this point in the history
Fixes #1279
  • Loading branch information
eritislami committed Jan 16, 2023
1 parent f26f934 commit cfb8ceb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions structs/MusicQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class MusicQueue {
public volume = config.DEFAULT_VOLUME || 100;
public loop = false;
public muted = false;
public waitTimeout: NodeJS.Timeout;
public waitTimeout: NodeJS.Timeout | null;
private queueLock = false;
private readyLock = false;

Expand Down Expand Up @@ -105,7 +105,8 @@ export class MusicQueue {
}

public enqueue(...songs: Song[]) {
if (typeof this.waitTimeout !== "undefined") clearTimeout(this.waitTimeout);
if (this.waitTimeout !== null) clearTimeout(this.waitTimeout);
this.waitTimeout = null;
this.songs = this.songs.concat(songs);
this.processQueue();
}
Expand All @@ -117,6 +118,8 @@ export class MusicQueue {

!config.PRUNING && this.textChannel.send(i18n.__("play.queueEnded")).catch(console.error);

if (this.waitTimeout !== null) return;

this.waitTimeout = setTimeout(() => {
if (this.connection.state.status !== VoiceConnectionStatus.Destroyed) {
try {
Expand Down

0 comments on commit cfb8ceb

Please sign in to comment.