diff --git a/src/Player.mjs b/src/Player.mjs index 63702f7..dab619b 100644 --- a/src/Player.mjs +++ b/src/Player.mjs @@ -1475,6 +1475,19 @@ export default class Player extends EventEmitter { this._skipping = true; this._radioAnnounced = false; this.queue.current = null; + + if (this.queue.isEmpty() && !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 })), system: true }); + } + this._stopMediaPlayer().then(() => { this._playingNext = false; if (!this.queue.isEmpty() && !this.leaving) { @@ -1484,18 +1497,6 @@ export default class Player extends EventEmitter { 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 })), system: true }); - } } }).catch(e => logger.error("[Player] skip stop error:", e.message)) .finally(() => { @@ -1513,6 +1514,20 @@ export default class Player extends EventEmitter { this.queue.data.splice(0, idx); this.queue.current = null; this._skipping = true; + + // If the queue is now empty after splicing, send queue-end immediately. + if (this.queue.isEmpty() && !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 })), system: true }); + } + this._stopMediaPlayer().then(() => { this._playingNext = false; if (!this.queue.isEmpty() && !this.leaving) { @@ -1522,18 +1537,6 @@ export default class Player extends EventEmitter { 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 })), system: true }); - } } }).catch(e => logger.error("[Player] skipTo stop error:", e.message)) .finally(() => { diff --git a/src/PlayerManager.mjs b/src/PlayerManager.mjs index 02b9d68..79a8074 100644 --- a/src/PlayerManager.mjs +++ b/src/PlayerManager.mjs @@ -971,12 +971,10 @@ export class PlayerManager { let ch = player.textChannel; const guildId = cleanId(player._guildId ?? ch?.guildId ?? ch?.guild?.id ?? getMessageGuildId({ channel: ch })); - if (!m?.system) { - const raw = this.settings.getServer(guildId)?.get("songAnnouncements"); - const disabled = raw === false || raw === 0 || - ["false","0","no","off","disable"].includes(String(raw).toLowerCase().trim()); - if (disabled) return; - } + const raw = this.settings.getServer(guildId)?.get("songAnnouncements"); + const disabled = raw === false || raw === 0 || + ["false","0","no","off","disable"].includes(String(raw).toLowerCase().trim()); + if (disabled) return; // If textChannel is not set (e.g. after reboot recovery via _spawnPlayer), // resolve it from the saved announcementChannelId or guild channels