mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
cleaning
This commit is contained in:
1 parent
06bcc93ced
commit
3d66043864
5 files changed
+37
-23
No files matched your search
+7
-3
@@ -39,6 +39,8 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||
});
|
||||
|
||||
p.on("autoleave", () => {
|
||||
const activeChannelId = String(p._channelId ?? cid).replace(/\D/g, "") || cid;
|
||||
const homeChannelId = String(p._home247Channel ?? activeChannelId).replace(/\D/g, "") || activeChannelId;
|
||||
const guildId = message.channel?.guildId
|
||||
?? message.channel?.guild?.id
|
||||
?? message.message?.guildId
|
||||
@@ -56,13 +58,15 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||
} catch (_) { return "%"; }
|
||||
})();
|
||||
const desc = is247
|
||||
? `Left channel <#${cid}> because of inactivity.`
|
||||
: `Left channel <#${cid}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
|
||||
? `Left channel <#${activeChannelId}> because of inactivity.`
|
||||
: `Left channel <#${activeChannelId}> because of inactivity.\nIf you want me to stay in voice, use \`${prefix}247 on/auto\``;
|
||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||
.setDescription(desc)
|
||||
.toJSON();
|
||||
message.channel.sendEmbed({ embeds: [embed] });
|
||||
this.players.playerMap.delete(cid);
|
||||
this.players.playerMap.delete(activeChannelId);
|
||||
if (activeChannelId !== cid) this.players.playerMap.delete(cid);
|
||||
if (homeChannelId !== activeChannelId) this.players.playerMap.delete(homeChannelId);
|
||||
p.destroy();
|
||||
});
|
||||
|
||||
|
||||
+13
-6
@@ -123,9 +123,15 @@ async function handle247(ctx, message, value) {
|
||||
channels.delete(id);
|
||||
save247Channels(set, channels);
|
||||
ctx.markIntentionalLeave?.(id);
|
||||
const player = ctx.players.playerMap.get(id);
|
||||
const player = ctx.players.playerMap.get(id)
|
||||
?? [...ctx.players.playerMap.values()].find(p =>
|
||||
cleanId(p?._channelId ?? "") === id &&
|
||||
cleanId(p?._guildId ?? "") === cleanId(guildId)
|
||||
);
|
||||
if (player) {
|
||||
ctx.players.playerMap.delete(id);
|
||||
const activeChannelId = cleanId(player._channelId ?? id);
|
||||
ctx.players.playerMap.delete(activeChannelId);
|
||||
if (activeChannelId !== id) ctx.players.playerMap.delete(id);
|
||||
await player.leave().catch(() => {});
|
||||
player.destroy();
|
||||
}
|
||||
@@ -137,10 +143,11 @@ async function handle247(ctx, message, value) {
|
||||
save247Channels(set, new Set());
|
||||
set.set("stay_247_mode", "off");
|
||||
for (const [chId, player] of [...ctx.players.playerMap.entries()]) {
|
||||
const ch = ctx.handler.client.channels.cache.get(chId);
|
||||
if (ch?.guild?.id === guildId || ch?.guildId === guildId) {
|
||||
ctx.markIntentionalLeave?.(chId);
|
||||
ctx.players.playerMap.delete(chId);
|
||||
if (cleanId(player?._guildId ?? "") === cleanId(guildId)) {
|
||||
const activeChannelId = cleanId(player._channelId ?? chId);
|
||||
ctx.markIntentionalLeave?.(activeChannelId);
|
||||
ctx.players.playerMap.delete(activeChannelId);
|
||||
if (activeChannelId !== chId) ctx.players.playerMap.delete(chId);
|
||||
await player.leave().catch(() => {});
|
||||
player.destroy();
|
||||
}
|
||||
|
||||
@@ -604,10 +604,10 @@ class Remix {
|
||||
if (wsListenerAttached && this._rawGatewayWsObj && this._rawGatewayWsObj !== wsObj) {
|
||||
try {
|
||||
if (typeof this._rawGatewayWsObj.removeEventListener === "function") {
|
||||
this._rawGatewayWsObj.removeEventListener("message", this._rawGatewayHandler);
|
||||
this._rawGatewayWsObj.removeEventListener("message", this._rawGatewayMessageListener ?? this._rawGatewayHandler);
|
||||
this._rawGatewayWsObj.removeEventListener("error", this._rawGatewayErrorHandler);
|
||||
} else if (typeof this._rawGatewayWsObj.off === "function") {
|
||||
this._rawGatewayWsObj.off("message", this._rawGatewayHandler);
|
||||
this._rawGatewayWsObj.off("message", this._rawGatewayMessageListener ?? this._rawGatewayHandler);
|
||||
this._rawGatewayWsObj.off("error", this._rawGatewayErrorHandler);
|
||||
}
|
||||
} catch (_) {}
|
||||
@@ -704,12 +704,13 @@ class Remix {
|
||||
this._rawGatewayErrorHandler = (err) => {
|
||||
logger.warn("[Gateway] Raw WS socket error (will reconnect):", err?.message ?? err);
|
||||
};
|
||||
this._rawGatewayMessageListener = (event) => this._rawGatewayHandler(event?.data ?? event);
|
||||
|
||||
if (typeof wsObj.addEventListener === "function") {
|
||||
wsObj.addEventListener("message", (event) => this._rawGatewayHandler(event.data));
|
||||
wsObj.addEventListener("message", this._rawGatewayMessageListener);
|
||||
wsObj.addEventListener("error", this._rawGatewayErrorHandler);
|
||||
} else if (typeof wsObj.on === "function") {
|
||||
wsObj.on("message", this._rawGatewayHandler);
|
||||
wsObj.on("message", this._rawGatewayMessageListener);
|
||||
wsObj.on("error", this._rawGatewayErrorHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user