From 722bda62c3adce88940b8dd0ac9bbcaeb24783df Mon Sep 17 00:00:00 2001 From: NoLogicAlan Date: Mon, 18 May 2026 01:42:59 +0300 Subject: [PATCH] fixed --- src/Player.mjs | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/src/Player.mjs b/src/Player.mjs index 1c1c1c5..3a5a858 100644 --- a/src/Player.mjs +++ b/src/Player.mjs @@ -1477,15 +1477,30 @@ export default class Player extends EventEmitter { this.queue.current = null; this._stopMediaPlayer().then(() => { this._playingNext = false; - this._skipping = false; - if (!this.queue.isEmpty() && !this.leaving) this.playNext(); - else { + if (!this.queue.isEmpty() && !this.leaving) { + this.playNext(); + } else { this.emit("stopplay"); if (!this._is247Enabled()) { this._startInactivityTimer(); } + // Send queue-end message when skipping the last track + if (!this._wasRadio && !this._queueEndedSent) { + this._queueEndedSent = true; + const prefix = (() => { + try { + return this.settingsMgr?.getServer?.(this._guildId)?.get?.("prefix") + ?? this.settings?.get?.("prefix") + ?? "%"; + } catch (_) { return "%"; } + })(); + this.emit("message", mkEmbed(this._t("responses._common.queueEnded", { prefix }))); + } } - }).catch(e => logger.error("[Player] skip stop error:", e.message)); + }).catch(e => logger.error("[Player] skip stop error:", e.message)) + .finally(() => { + this._skipping = false; + }); return ":track_next: Skipped"; } @@ -1500,15 +1515,31 @@ export default class Player extends EventEmitter { this._skipping = true; this._stopMediaPlayer().then(() => { this._playingNext = false; - this._skipping = false; - if (!this.queue.isEmpty() && !this.leaving) this.playNext(); - else { + if (!this.queue.isEmpty() && !this.leaving) { + this.playNext(); + } else { this.emit("stopplay"); if (!this._is247Enabled()) { this._startInactivityTimer(); } + // Send queue-end message when skipping to a position beyond remaining tracks + if (!this._wasRadio && !this._queueEndedSent) { + this._queueEndedSent = true; + const prefix = (() => { + try { + return this.settingsMgr?.getServer?.(this._guildId)?.get?.("prefix") + ?? this.settings?.get?.("prefix") + ?? "%"; + } catch (_) { return "%"; } + })(); + this.emit("message", mkEmbed(this._t("responses._common.queueEnded", { prefix }))); + } } - }).catch(e => logger.error("[Player] skipTo stop error:", e.message)); + }).catch(e => logger.error("[Player] skipTo stop error:", e.message)) + .finally(() => { + // Always reset _skipping — even if _stopMediaPlayer() threw. + this._skipping = false; + }); return `:track_next: Skipped to position ${position}`; }