This commit is contained in:
NoLogicAlan committed 2026-05-04 16:25:22 +03:00
1 parent 06bcc93ced
commit 3d66043864
5 files changed
+37 -23

No files matched your search

+5 -4
View File
@@ -188,10 +188,10 @@ export class MoonlinkManager extends EventEmitter {
if (this._rawWsHandler && this._rawWsObj && this._rawWsObj !== wsObj) {
try {
if (typeof this._rawWsObj.removeEventListener === "function") {
this._rawWsObj.removeEventListener("message", this._rawWsHandler);
this._rawWsObj.removeEventListener("message", this._rawWsMessageListener ?? this._rawWsHandler);
this._rawWsObj.removeEventListener("error", this._rawWsErrorHandler);
} else if (typeof this._rawWsObj.off === "function") {
this._rawWsObj.off("message", this._rawWsHandler);
this._rawWsObj.off("message", this._rawWsMessageListener ?? this._rawWsHandler);
this._rawWsObj.off("error", this._rawWsErrorHandler);
}
} catch (_) {}
@@ -216,12 +216,13 @@ export class MoonlinkManager extends EventEmitter {
this._rawWsErrorHandler = (err) => {
logger.warn("[MoonlinkManager] Raw WS socket error (will reconnect):", err?.message ?? err);
};
this._rawWsMessageListener = (event) => this._rawWsHandler(event?.data ?? event);
if (typeof wsObj.addEventListener === "function") {
wsObj.addEventListener("message", this._rawWsHandler);
wsObj.addEventListener("message", this._rawWsMessageListener);
wsObj.addEventListener("error", this._rawWsErrorHandler);
} else if (typeof wsObj.on === "function") {
wsObj.on("message", this._rawWsHandler);
wsObj.on("message", this._rawWsMessageListener);
wsObj.on("error", this._rawWsErrorHandler);
}
+7 -6
View File
@@ -292,18 +292,19 @@ export class PlayerManager {
const serverId = msg.channel?.server_id ?? msg.channel?.serverId ??
msg.message?.server_id ?? msg.message?.serverId;
if (serverId) {
cid = [...this.playerMap.keys()].find((id) => {
const ch = this.commands.client?.channels?.get(id) ??
this.commands.client?.channels?.cache?.get(id);
return ch?.guildId === serverId || ch?.server_id === serverId || ch?.serverId === serverId;
});
const matchedEntry = [...this.playerMap.entries()].find(([, player]) =>
String(player?._guildId ?? "").replace(/\D/g, "") === String(serverId).replace(/\D/g, "")
);
cid = matchedEntry?.[0] ?? null;
}
}
const player = cid ? this.playerMap.get(cid) : null;
if (!player) return msg.replyEmbed(mkEmbed("I'm not in a voice channel."));
this.playerMap.delete(cid);
const activeChannelId = String(player._channelId ?? cid).replace(/\D/g, "") || cid;
this.playerMap.delete(activeChannelId);
if (activeChannelId !== cid) this.playerMap.delete(cid);
await msg.replyEmbed(mkEmbed("✅ Successfully Left"));
await player.leave();
player.destroy();