fix(music): resolve ghost players on channel/guild delete and fix clear command NaN range

This commit is contained in:
NoLogicAlan committed 2026-10-24 04:00:25 +03:00
1 parent a780ec22c8
commit 618ecb1a0b
9 files changed
+94 -13

No files matched your search

+1
View File
@@ -263,6 +263,7 @@ const DisplayMixin = {
*/
announceSong(s) {
if (!s) return;
if (this._destroyed || this.leaving || (!this._voiceConn && !this.connection)) return;
if (s.type === "radio") {
this.emit("message", { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this._t("responses.radio.nowPlaying", {
+2
View File
@@ -720,6 +720,7 @@ class Player extends EventEmitter {
this._onLavalinkPlayerDisconnect = null;
}
}
this.queue?.reset();
this.leaving = true;
this._stopInactivityTimer();
this._autoplay = false;
@@ -747,6 +748,7 @@ class Player extends EventEmitter {
vm.leaveChannel(this._channelId);
} catch(e) { /* best effort */ }
}
this.removeAllListeners();
} catch (e) {
logger.error("[Player] destroy error:", e.message);
}
+5 -1
View File
@@ -84,10 +84,14 @@ export class Queue extends EventEmitter {
*/
removeRange(from, to) {
if (this.isEmpty()) return "The queue is empty.";
if (typeof from !== "number" || typeof to !== "number" || !Number.isFinite(from) || !Number.isFinite(to)) {
return "Invalid range.";
}
const start = Math.max(0, Math.min(from, to));
const end = Math.min(this.data.length - 1, Math.max(from, to));
if (start >= this.data.length) return "Index out of bounds";
if (start >= this.data.length || end < start) return "Index out of bounds";
const deleteCount = (end - start) + 1;
if (deleteCount <= 0) return "Invalid range.";
const removed = this.data.splice(start, deleteCount);
this.emit("queue", { type: "removeRange", data: { start, end, count: removed.length, old: this.data.slice(), removed, new: this.data } });
return { count: removed.length, removed };