mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
hotfix ( idk )
This commit is contained in:
1 parent
092268281a
commit
862f326996
4 files changed
+77
-5
No files matched your search
@@ -301,6 +301,7 @@ export class Remix {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.revoice = FluxerRevoice.getInstance(client);
|
this.revoice = FluxerRevoice.getInstance(client);
|
||||||
|
client._remix = this;
|
||||||
|
|
||||||
this.playerContext = {
|
this.playerContext = {
|
||||||
client: this.client,
|
client: this.client,
|
||||||
|
|||||||
@@ -1105,6 +1105,10 @@ export class GatewayHandler {
|
|||||||
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)) {
|
} else if (remix.revoice?._intentionalDisconnects?.has?.(cleanOld)) {
|
||||||
logger.voiceState(`[VoiceState] Bot disconnected from ${cleanOld} — intentional (revoice).`);
|
logger.voiceState(`[VoiceState] Bot disconnected from ${cleanOld} — intentional (revoice).`);
|
||||||
|
} else if (this._isGuildMoveInProgress(cleanGuild, cleanOld)) {
|
||||||
|
logger.voiceState(`[VoiceState] Bot disconnected from ${cleanOld} — guild move in progress, skipping.`);
|
||||||
|
} else if (this._bootRecoveryActive) {
|
||||||
|
logger.voiceState(`[VoiceState] Bot disconnected from ${cleanOld} — boot recovery active, skipping.`);
|
||||||
} else {
|
} else {
|
||||||
const set = remix.settingsMgr.getServer(guildId);
|
const set = remix.settingsMgr.getServer(guildId);
|
||||||
const mode = set ? get247ChannelMode(set, cleanOld) : "off";
|
const mode = set ? get247ChannelMode(set, cleanOld) : "off";
|
||||||
@@ -1155,6 +1159,9 @@ export class GatewayHandler {
|
|||||||
/** @type {Map<string, number>} Channel IDs with retry attempt counts */
|
/** @type {Map<string, number>} Channel IDs with retry attempt counts */
|
||||||
_rejoinAttempts = new Map();
|
_rejoinAttempts = new Map();
|
||||||
|
|
||||||
|
/** @type {boolean} Whether boot recovery (rejoin247Channels) is currently running */
|
||||||
|
_bootRecoveryActive = false;
|
||||||
|
|
||||||
/** @type {number} Maximum number of rejoin retry attempts */
|
/** @type {number} Maximum number of rejoin retry attempts */
|
||||||
static MAX_REJOIN_RETRIES = 3;
|
static MAX_REJOIN_RETRIES = 3;
|
||||||
|
|
||||||
@@ -1245,6 +1252,12 @@ export class GatewayHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (remix.revoice?._intentionalDisconnects?.has?.(cleanChannelId)) {
|
||||||
|
logger.voice247(`[Rejoin] Channel ${cleanChannelId} was intentionally left (revoice) — skipping.`);
|
||||||
|
this._rejoinAttempts.delete(cleanChannelId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const channel = remix.client?.channels?.get?.(cleanChannelId);
|
const channel = remix.client?.channels?.get?.(cleanChannelId);
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
logger.voice247(`[Rejoin] Channel ${cleanChannelId} no longer exists — skipping.`);
|
logger.voice247(`[Rejoin] Channel ${cleanChannelId} no longer exists — skipping.`);
|
||||||
@@ -1272,6 +1285,48 @@ export class GatewayHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a guild-move operation is currently in progress for the
|
||||||
|
* given guild and old channel. During a move, Fluxer sends two
|
||||||
|
* VoiceStateUpdate events (leave old + join new) in rapid succession;
|
||||||
|
* the "leave" should NOT be treated as an unexpected disconnect.
|
||||||
|
*
|
||||||
|
* @param {string} guildId The guild ID to check
|
||||||
|
* @param {string} oldChannelId The channel the bot appears to have left
|
||||||
|
* @returns {boolean} True if a move is in progress and the disconnect should be ignored
|
||||||
|
*/
|
||||||
|
_isGuildMoveInProgress(guildId, oldChannelId) {
|
||||||
|
const { remix } = this;
|
||||||
|
const cleanGuild = cleanId(guildId);
|
||||||
|
const cleanOld = cleanId(oldChannelId);
|
||||||
|
if (!cleanGuild || !cleanOld) return false;
|
||||||
|
|
||||||
|
const activePlayers = [...remix.players.playerMap.values()].filter(
|
||||||
|
p => !p._destroyed && cleanId(p._guildId ?? "") === cleanGuild
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const player of activePlayers) {
|
||||||
|
const playerChannel = cleanId(player._channelId ?? "");
|
||||||
|
if (playerChannel && playerChannel !== cleanOld) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remix.players._pendingJoins) {
|
||||||
|
for (const pendingId of remix.players._pendingJoins) {
|
||||||
|
const cleanPending = cleanId(pendingId);
|
||||||
|
if (cleanPending && cleanPending !== cleanOld) {
|
||||||
|
const pendingChannel = remix.client?.channels?.get?.(cleanPending);
|
||||||
|
if (pendingChannel && cleanId(pendingChannel.guildId ?? "") === cleanGuild) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke after the bot has connected and Moonlink has been initialised.
|
* Invoke after the bot has connected and Moonlink has been initialised.
|
||||||
* Seeds voice states, attaches raw WS listener, kicks off presence rotation,
|
* Seeds voice states, attaches raw WS listener, kicks off presence rotation,
|
||||||
@@ -1413,6 +1468,7 @@ export class GatewayHandler {
|
|||||||
* avoid overwhelming the LiveKit server with concurrent track publications.
|
* avoid overwhelming the LiveKit server with concurrent track publications.
|
||||||
*/
|
*/
|
||||||
async rejoin247Channels() {
|
async rejoin247Channels() {
|
||||||
|
this._bootRecoveryActive = true;
|
||||||
const { remix } = this;
|
const { remix } = this;
|
||||||
const channelsToRejoin = [];
|
const channelsToRejoin = [];
|
||||||
|
|
||||||
@@ -1544,6 +1600,8 @@ 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.`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setTimeout(() => { this._bootRecoveryActive = false; }, 15_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+6
-2
@@ -1195,6 +1195,12 @@ export default class Player extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const channelId = this._channelId;
|
const channelId = this._channelId;
|
||||||
|
if (this._revoice && channelId && typeof this._revoice.markIntentionalDisconnect === "function") {
|
||||||
|
this._revoice.markIntentionalDisconnect(channelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.connection.leave();
|
||||||
|
|
||||||
if (this._revoice && channelId) {
|
if (this._revoice && channelId) {
|
||||||
try {
|
try {
|
||||||
if (typeof this._revoice.deleteConnection === "function") {
|
if (typeof this._revoice.deleteConnection === "function") {
|
||||||
@@ -1205,8 +1211,6 @@ export default class Player extends EventEmitter {
|
|||||||
} catch(e) { logger.warn("[Player] Delete connection on leave error:", e?.message); }
|
} catch(e) { logger.warn("[Player] Delete connection on leave error:", e?.message); }
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.connection.leave();
|
|
||||||
|
|
||||||
this.queue.reset();
|
this.queue.reset();
|
||||||
this.connection = null;
|
this.connection = null;
|
||||||
this._paused = false;
|
this._paused = false;
|
||||||
|
|||||||
@@ -179,7 +179,8 @@ export class FluxerVoiceConnection extends EventEmitter {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn("[FluxerVoiceConnection] Room disconnect error:", e?.message);
|
logger.warn("[FluxerVoiceConnection] Room disconnect error:", e?.message);
|
||||||
}
|
}
|
||||||
} else if (this._nativeConn && typeof this._nativeConn.disconnect === "function") {
|
}
|
||||||
|
if (this._nativeConn && typeof this._nativeConn.disconnect === "function") {
|
||||||
try {
|
try {
|
||||||
await this._nativeConn.disconnect();
|
await this._nativeConn.disconnect();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -275,6 +276,12 @@ export class FluxerRevoice extends EventEmitter {
|
|||||||
this._intentionalDisconnects.delete(key);
|
this._intentionalDisconnects.delete(key);
|
||||||
this._intentionalDisconnectTokens.delete(key);
|
this._intentionalDisconnectTokens.delete(key);
|
||||||
}, 10_000));
|
}, 10_000));
|
||||||
|
const cleanChannelId = key.replace(/\D/g, "");
|
||||||
|
if (this.client?._remix?.intentionalLeaves && !this.client._remix.intentionalLeaves.has(cleanChannelId)) {
|
||||||
|
this.client._remix.intentionalLeaves.set(cleanChannelId, setTimeout(() => {
|
||||||
|
this.client._remix.intentionalLeaves.delete(cleanChannelId);
|
||||||
|
}, 10_000));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,7 +359,8 @@ export class FluxerRevoice extends EventEmitter {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn("[FluxerRevoice] Stale room disconnect error:", e?.message);
|
logger.warn("[FluxerRevoice] Stale room disconnect error:", e?.message);
|
||||||
}
|
}
|
||||||
} else if (existing._nativeConn && typeof existing._nativeConn.disconnect === "function") {
|
}
|
||||||
|
if (existing._nativeConn && typeof existing._nativeConn.disconnect === "function") {
|
||||||
try {
|
try {
|
||||||
await existing._nativeConn.disconnect();
|
await existing._nativeConn.disconnect();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -546,7 +554,6 @@ export class FluxerRevoice extends EventEmitter {
|
|||||||
const isIntentional = this._intentionalDisconnects.has(String(channelId));
|
const isIntentional = this._intentionalDisconnects.has(String(channelId));
|
||||||
const reasonLabel = isIntentional ? "intentional" : (reason ?? "unexpected");
|
const reasonLabel = isIntentional ? "intentional" : (reason ?? "unexpected");
|
||||||
logger.player(`[FluxerRevoice] Room disconnected: ${reasonLabel}`);
|
logger.player(`[FluxerRevoice] Room disconnected: ${reasonLabel}`);
|
||||||
this._intentionalDisconnects.delete(String(channelId));
|
|
||||||
conn._connected = false;
|
conn._connected = false;
|
||||||
conn._destroyed = true;
|
conn._destroyed = true;
|
||||||
|
|
||||||
@@ -562,7 +569,9 @@ export class FluxerRevoice extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (conn.listenerCount("disconnect") > 0) {
|
||||||
conn.emit("disconnect");
|
conn.emit("disconnect");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
room.on(LKRoomEvent.ParticipantConnected, (participant) => {
|
room.on(LKRoomEvent.ParticipantConnected, (participant) => {
|
||||||
|
|||||||
Reference in new issue
Block a user