From e435af7eb2060d0704396fdd0bbfe7f728d8b84e Mon Sep 17 00:00:00 2001 From: NoLogicAlan Date: Wed, 2 Sep 2026 00:56:14 +0300 Subject: [PATCH] ... --- commands/leave.mjs | 22 +++++----------------- src/GatewayHandler.mjs | 13 +++++++++++-- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/commands/leave.mjs b/commands/leave.mjs index c4888b1..37488b1 100644 --- a/commands/leave.mjs +++ b/commands/leave.mjs @@ -114,25 +114,13 @@ export async function run(msg, data) { const activeChannelId = cleanId(player._channelId) || targetChannelId; const homeChannelId = cleanId(player._home247Channel) || activeChannelId; - // If this channel has 24/7 enabled, remove it from the saved list first. - // This prevents the disconnect handler from scheduling an auto-rejoin loop. const set = this.getSettings(msg); const raw = set?.get("stay_247"); - const ch247 = (!raw || raw === "none") - ? new Set() - : Array.isArray(raw) - ? new Set(raw.map(id => cleanId(id)).filter(Boolean)) - : new Set([cleanId(raw)]); + const was247 = !!raw && raw !== "none" && + (Array.isArray(raw) + ? raw.map(id => cleanId(id)).some(id => id === activeChannelId || id === homeChannelId) + : [cleanId(raw)].some(id => id === activeChannelId || id === homeChannelId)); - const was247 = ch247.has(activeChannelId) || ch247.has(homeChannelId); - - if (was247) { - const target = ch247.has(activeChannelId) ? activeChannelId : homeChannelId; - ch247.delete(target); - set.set("stay_247", ch247.size > 0 ? [...ch247] : "none"); - } - - // Mark as intentional leave so the disconnect handler doesn't also try to rejoin this.markIntentionalLeave(activeChannelId); this.players.playerMap.delete(activeChannelId); this.players._unindexPlayer(player._guildId, activeChannelId); @@ -148,6 +136,6 @@ export async function run(msg, data) { await player.leave().catch(() => {}); player.destroy(); - const label247 = was247 ? " 24/7 disabled." : ""; + const label247 = was247 ? " (24/7 still saved — use `" + this.handler.getPrefix(cleanGuildId) + "247` to disable it.)" : ""; msg.reply(this.t(msg, "responses.leave.left") + label247); } diff --git a/src/GatewayHandler.mjs b/src/GatewayHandler.mjs index df34a8d..357eb2a 100644 --- a/src/GatewayHandler.mjs +++ b/src/GatewayHandler.mjs @@ -1316,6 +1316,17 @@ export class GatewayHandler { */ async rejoin247Channels() { this._bootRecoveryActive = true; + try { + await this._rejoin247ChannelsInner(); + } catch (err) { + logger.warn("[BootRecovery] 24/7 boot recovery crashed:", err?.message ?? err); + } finally { + this._bootRecoveryActive = false; + } + } + + /** @private Inner boot-recovery loop. The flag reset is handled by the caller's finally block. */ + async _rejoin247ChannelsInner() { const { remix } = this; const channelsToRejoin = []; @@ -1429,8 +1440,6 @@ export class GatewayHandler { logger.voice247( `[BootRecovery] Boot recovery complete. ${channelsToRejoin.length} channel(s) processed.` ); - - this._bootRecoveryActive = false; } /**