This commit is contained in:
NoLogicAlan committed 2026-05-16 18:34:00 +03:00
1 parent b75ea56ca9
commit d53cfd88d6
2 files changed
+34 -5

No files matched your search

+27 -5
View File
@@ -1044,11 +1044,28 @@ export class GatewayHandler {
); );
return; return;
} }
// Replace the old channel with the new one in stay_247.
// Previously this kept BOTH channels, causing unbounded growth // ── Multi-voice guard ──────────────────────────────────────────
// in the stay_247 list (e.g. guild 1480202154270605526 ended up const currentGuildPlayers = [...remix.players.playerMap.values()].filter(p =>
// with 5+ channels). Now we remove the old channel and add the String(p?._guildId ?? "").replace(/\D/g, "") === String(guildId ?? "").replace(/\D/g, "")
// new one so the list stays at the correct size. );
if (currentGuildPlayers.length > 1) {
if (!channels.has(cleanId)) {
channels.add(cleanId);
set.set("stay_247", [...channels]);
const modes2 = set.get("stay_247_modes");
if (modes2 && typeof modes2 === "object" && !Array.isArray(modes2) && !modes2[cleanId]) {
modes2[cleanId] = modes2[cleanOld] ?? "auto";
set.set("stay_247_modes", modes2);
}
logger.voice247(
`[247] Added stay_247 channel ${cleanId} (kept ${cleanOld}) — guild has ${currentGuildPlayers.length} active players`
);
}
return;
}
// Single-voice guild: genuine move — replace old channel with new.
channels.delete(cleanOld); channels.delete(cleanOld);
channels.add(cleanId); channels.add(cleanId);
set.set("stay_247", [...channels]); set.set("stay_247", [...channels]);
@@ -1081,6 +1098,11 @@ export class GatewayHandler {
const cleanGuild = String(guildId).replace(/\D/g, ""); const cleanGuild = String(guildId).replace(/\D/g, "");
if (remix.intentionalLeaves.has(cleanOld)) { if (remix.intentionalLeaves.has(cleanOld)) {
logger.voiceState(`[VoiceState] Bot disconnected from ${cleanOld} — intentional leave.`); logger.voiceState(`[VoiceState] Bot disconnected from ${cleanOld} — intentional leave.`);
} else if (remix.revoice?._intentionalDisconnects?.has?.(cleanOld)) {
// The player's destroy() or FluxerRevoice internally marked this
// disconnect as intentional (e.g. cleaning up a stale connection
// during a rejoin). Don't schedule another rejoin.
logger.voiceState(`[VoiceState] Bot disconnected from ${cleanOld} — intentional (revoice).`);
} else { } else {
// Check 24/7 mode for this channel // Check 24/7 mode for this channel
const set = remix.settingsMgr.getServer(guildId); const set = remix.settingsMgr.getServer(guildId);
+7
View File
@@ -1365,6 +1365,13 @@ export default class Player extends EventEmitter {
const connToDestroy = this.connection; const connToDestroy = this.connection;
this.connection = null; this.connection = null;
this._mediaPlayer = null; this._mediaPlayer = null;
// Mark the disconnect as intentional BEFORE disconnecting so that
// the RoomEvent.Disconnected handler in FluxerRevoice (and the
// VoiceState bot-disconnect handler in GatewayHandler) do NOT treat
// this as an unexpected drop and schedule a spurious rejoin.
if (this._revoice && this._channelId) {
try { this._revoice.markIntentionalDisconnect(this._channelId); } catch (_) {}
}
this._stopMediaPlayer().catch(() => {}).then(() => { this._stopMediaPlayer().catch(() => {}).then(() => {
if (connToDestroy) { if (connToDestroy) {
try { connToDestroy.removeAllListeners?.(); } catch (_) {} try { connToDestroy.removeAllListeners?.(); } catch (_) {}