mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix(music): resolve ghost players on channel/guild delete and fix clear command NaN range
This commit is contained in:
1 parent
a780ec22c8
commit
618ecb1a0b
9 files changed
+94
-13
No files matched your search
@@ -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", {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in new issue
Block a user