mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
great and not great
This commit is contained in:
1 parent
ed622ee453
commit
a78edeaa9a
4 files changed
+313
-238
No files matched your search
+9
-11
@@ -1255,15 +1255,18 @@ export class GatewayHandler {
|
||||
`guild is 401-banned (${Math.round((banExpiry - Date.now()) / 1000)}s remaining).`
|
||||
);
|
||||
// Remove the old player entry and destroy it
|
||||
const bannedPlayer = remix.players.playerMap.get(cleanOld);
|
||||
remix.players.playerMap.delete(cleanOld);
|
||||
try { remix.players.playerMap.get(cleanOld)?.destroy(); } catch (_) {}
|
||||
try { bannedPlayer?.destroy(); } catch (_) {}
|
||||
return;
|
||||
}
|
||||
|
||||
// Match the specific player by channel ID
|
||||
const player = remix.players.playerMap.get(cleanOld);
|
||||
if (player && !player.leaving) {
|
||||
logger.voice247("[247] Fluxer gateway disconnected us. Forcing player recovery...");
|
||||
logger.voice247(
|
||||
`[247] Fluxer gateway disconnected ${cleanOld} in guild ${guildId} — scheduling 24/7 respawn.`
|
||||
);
|
||||
|
||||
// Set a gateway disconnect cooldown for this guild to
|
||||
// prevent recovery cascades. If recovery rejoins and the
|
||||
@@ -1273,17 +1276,12 @@ export class GatewayHandler {
|
||||
// Auto-clear the cooldown after 30 seconds
|
||||
setTimeout(() => this._gatewayDisconnectCooldown.delete(cleanGuild), 30_000);
|
||||
|
||||
// Mark the disconnect reason on the player for smarter recovery
|
||||
// Mark the disconnect reason before shutting the player down.
|
||||
player._lastDisconnectReason = "gateway";
|
||||
player._lastDisconnectTime = Date.now();
|
||||
|
||||
if (typeof player._recoverConnection === "function") {
|
||||
player._recoverConnection();
|
||||
} else {
|
||||
remix.players.playerMap.delete(cleanOld);
|
||||
try { player.destroy(); } catch (_) {}
|
||||
this.recoveryManager.scheduleSpawn(guildId, cleanOld, this.T.rejoin247Delay, "gateway-disconnect");
|
||||
}
|
||||
remix.players.playerMap.delete(cleanOld);
|
||||
try { player.destroy(); } catch (_) {}
|
||||
this.recoveryManager.scheduleSpawn(guildId, cleanOld, this.T.rejoin247Delay, "gateway-disconnect");
|
||||
} else {
|
||||
this.recoveryManager.scheduleSpawn(guildId, cleanOld, this.T.rejoin247Delay, "gateway-disconnect");
|
||||
}
|
||||
|
||||
+13
-8
@@ -372,18 +372,16 @@ export class PlayerManager {
|
||||
const seedObserved = (channelId) => {
|
||||
const cleanChannelId = cleanId(channelId);
|
||||
if (!cleanChannelId) return null;
|
||||
if (!this.observedVoiceUsers?.has(userId)) {
|
||||
const current = this.observedVoiceUsers?.get?.(userId) ?? null;
|
||||
if (
|
||||
cleanId(current?.guildId) !== cleanGuild ||
|
||||
cleanId(current?.channelId) !== cleanChannelId
|
||||
) {
|
||||
this.observedVoiceUsers?.set(userId, { channelId: cleanChannelId, guildId: cleanGuild });
|
||||
}
|
||||
return cleanId(this.observedVoiceUsers?.get(userId)?.channelId) || cleanChannelId;
|
||||
return cleanChannelId;
|
||||
};
|
||||
|
||||
const observed = this.observedVoiceUsers?.get?.(userId);
|
||||
if (cleanId(observed?.guildId) === cleanGuild) {
|
||||
const observedChannelId = cleanId(observed?.channelId);
|
||||
if (observedChannelId) return observedChannelId;
|
||||
}
|
||||
|
||||
try {
|
||||
const vm = getVoiceManager(this.commands.client);
|
||||
const voiceChannelId = vm?.getVoiceChannelId?.(guildId, userId);
|
||||
@@ -479,6 +477,13 @@ export class PlayerManager {
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
const observed = this.observedVoiceUsers?.get?.(userId);
|
||||
if (cleanId(observed?.guildId) === cleanGuild) {
|
||||
const observedChannelId = cleanId(observed?.channelId);
|
||||
if (observedChannelId) return observedChannelId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user