mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
hotfix
This commit is contained in:
1 parent
923f9f2ce3
commit
ada28d465b
2 files changed
+32
-5
No files matched your search
@@ -18,6 +18,7 @@ import { getMessageGuildId } from "../ui/index.mjs";
|
||||
import { applyMixins } from "../utils/mixins.mjs";
|
||||
import PlayerEventsMixin, { getPlayerChannelId } from "./PlayerEventsMixin.mjs";
|
||||
import PlayerLifecycleMixin from "./PlayerLifecycleMixin.mjs";
|
||||
import { isPlayerConnectionDead, detachPlayerFromManager } from "../utils/Helpers247.mjs";
|
||||
|
||||
|
||||
/** @class PlayerManager @description Manages all Player instances. Handles player lifecycle (spawn, join, leave, destroy), voice channel resolution, dashboard events, and autoleave suppression for 24/7 channels. */
|
||||
@@ -168,6 +169,28 @@ export class PlayerManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evict `player` from playerMap/index/scrobble-timers and destroy it if its
|
||||
* underlying voice connection is dead. Zombie players (still mapped, but
|
||||
* disconnected from LiveKit — e.g. after a manual voice-kick that the
|
||||
* autoleave suppression rules chose not to clean up) must never be handed
|
||||
* back to a command as if they were live; every caller that fetches an
|
||||
* "existing" player from playerMap should run it through this check first.
|
||||
* @param {Player|null} player
|
||||
* @param {string|null} [fallbackChannelId=null]
|
||||
* @returns {boolean} True if the player was dead and has been evicted.
|
||||
*/
|
||||
_evictIfDead(player, fallbackChannelId = null) {
|
||||
if (!player || !isPlayerConnectionDead(player)) return false;
|
||||
logger.voice247(
|
||||
`[PlayerManager] getPlayer() found a zombie player (channel ${fallbackChannelId ?? player?._channelId}) — evicting.`
|
||||
);
|
||||
const remix = this.commands?.client?._remix ?? null;
|
||||
detachPlayerFromManager(remix ?? { players: this }, player, fallbackChannelId);
|
||||
try { player.destroy(); } catch (_) {}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Find a player by its channel ID across all guilds. @param {string} channelId @returns {Player|null} */
|
||||
getPlayerByChannelId(channelId) {
|
||||
const cId = cleanId(channelId);
|
||||
@@ -191,7 +214,8 @@ export class PlayerManager {
|
||||
if (cleanUserChannelId) {
|
||||
const player = this.playerMap.get(cleanUserChannelId)
|
||||
?? this.getPlayerByGuildAndChannel(cleanGuildId, cleanUserChannelId);
|
||||
if (player) {
|
||||
if (player && this._evictIfDead(player, cleanUserChannelId)) {
|
||||
} else if (player) {
|
||||
player.textChannel = message.channel?.channel ?? message.channel;
|
||||
try {
|
||||
const textChannelId = message?.channel?.id ?? message?.channel?.channel?.id ?? null;
|
||||
@@ -208,9 +232,8 @@ export class PlayerManager {
|
||||
}
|
||||
}
|
||||
|
||||
const serverPlayers = cleanGuildId
|
||||
? this.getGuildPlayers(cleanGuildId)
|
||||
: [];
|
||||
const serverPlayers = (cleanGuildId ? this.getGuildPlayers(cleanGuildId) : [])
|
||||
.filter(([chId, player]) => !this._evictIfDead(player, chId));
|
||||
|
||||
if (serverPlayers.length > 0) {
|
||||
const channelList = serverPlayers.map(([chId]) => `<#${chId}>`).join(" or ");
|
||||
|
||||
@@ -444,8 +444,12 @@ const VoiceStateRouting = {
|
||||
const leavePlayer = remix.players.playerMap.get(cleanOld);
|
||||
if (leavePlayer && !leavePlayer.leaving && !leavePlayer._destroyed) {
|
||||
logger.voiceState(
|
||||
`[VoiceState] Bot disconnected from ${cleanOld} (24/7 mode: ${mode}) — emitting autoleave.`
|
||||
`[VoiceState] Bot disconnected from ${cleanOld} (24/7 mode: ${mode}) — evicting stale player and emitting autoleave.`
|
||||
);
|
||||
const homeChannel = cleanId(leavePlayer._home247Channel ?? "");
|
||||
remix.players.playerMap.delete(cleanOld);
|
||||
if (homeChannel && homeChannel !== cleanOld) remix.players.playerMap.delete(homeChannel);
|
||||
try { remix.players._unindexPlayer?.(leavePlayer._guildId, cleanOld); } catch (_) {}
|
||||
leavePlayer.emit("autoleave");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user