This commit is contained in:
NoLogicAlan committed 2026-09-02 00:56:14 +03:00
1 parent 20cc1bcafb
commit e435af7eb2
2 files changed
+16 -19

No files matched your search

+5 -17
View File
@@ -114,25 +114,13 @@ export async function run(msg, data) {
const activeChannelId = cleanId(player._channelId) || targetChannelId; const activeChannelId = cleanId(player._channelId) || targetChannelId;
const homeChannelId = cleanId(player._home247Channel) || activeChannelId; 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 set = this.getSettings(msg);
const raw = set?.get("stay_247"); const raw = set?.get("stay_247");
const ch247 = (!raw || raw === "none") const was247 = !!raw && raw !== "none" &&
? new Set() (Array.isArray(raw)
: Array.isArray(raw) ? raw.map(id => cleanId(id)).some(id => id === activeChannelId || id === homeChannelId)
? new Set(raw.map(id => cleanId(id)).filter(Boolean)) : [cleanId(raw)].some(id => id === activeChannelId || id === homeChannelId));
: new Set([cleanId(raw)]);
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.markIntentionalLeave(activeChannelId);
this.players.playerMap.delete(activeChannelId); this.players.playerMap.delete(activeChannelId);
this.players._unindexPlayer(player._guildId, activeChannelId); this.players._unindexPlayer(player._guildId, activeChannelId);
@@ -148,6 +136,6 @@ export async function run(msg, data) {
await player.leave().catch(() => {}); await player.leave().catch(() => {});
player.destroy(); 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); msg.reply(this.t(msg, "responses.leave.left") + label247);
} }
+11 -2
View File
@@ -1316,6 +1316,17 @@ export class GatewayHandler {
*/ */
async rejoin247Channels() { async rejoin247Channels() {
this._bootRecoveryActive = true; 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 { remix } = this;
const channelsToRejoin = []; const channelsToRejoin = [];
@@ -1429,8 +1440,6 @@ export class GatewayHandler {
logger.voice247( logger.voice247(
`[BootRecovery] Boot recovery complete. ${channelsToRejoin.length} channel(s) processed.` `[BootRecovery] Boot recovery complete. ${channelsToRejoin.length} channel(s) processed.`
); );
this._bootRecoveryActive = false;
} }
/** /**