mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
test
This commit is contained in:
1 parent
57f3d9c481
commit
7fc56b5bca
2 files changed
+27
-15
No files matched your search
@@ -256,6 +256,12 @@ class Remix {
|
|||||||
try {
|
try {
|
||||||
await p.join(cleanChannelId);
|
await p.join(cleanChannelId);
|
||||||
|
|
||||||
|
// Record the intended 247 home channel for this player.
|
||||||
|
// This is the channel spawnPlayer was called with — it doesn't
|
||||||
|
// change when the bot is temporarily moved to a transit channel,
|
||||||
|
// so _is247Enabled() can always check the right channel per-player.
|
||||||
|
p._home247Channel = cleanChannelId;
|
||||||
|
|
||||||
// ==== RESTORE STATE IF RECOVERING ====
|
// ==== RESTORE STATE IF RECOVERING ====
|
||||||
if (recoveryData) {
|
if (recoveryData) {
|
||||||
if (recoveryData.textChannelId) {
|
if (recoveryData.textChannelId) {
|
||||||
@@ -878,11 +884,10 @@ class Remix {
|
|||||||
if (existingPlayer && cleanId !== cleanOld) {
|
if (existingPlayer && cleanId !== cleanOld) {
|
||||||
this.players.playerMap.delete(cleanOld);
|
this.players.playerMap.delete(cleanOld);
|
||||||
this.players.playerMap.set(cleanId, existingPlayer);
|
this.players.playerMap.set(cleanId, existingPlayer);
|
||||||
// CRITICAL: also update the player's own _channelId so that
|
// Update both _channelId and _home247Channel so _recoverConnection
|
||||||
// _recoverConnection, _is247Enabled, and _hasHumansInChannel
|
// and _is247Enabled always reference the correct current channel.
|
||||||
// all use the correct channel. Without this they keep referencing
|
|
||||||
// the old channel even after the bot has moved.
|
|
||||||
existingPlayer._channelId = cleanId;
|
existingPlayer._channelId = cleanId;
|
||||||
|
existingPlayer._home247Channel = cleanId;
|
||||||
logger.voice247(`[247] Re-keyed playerMap ${cleanOld} → ${cleanId}`);
|
logger.voice247(`[247] Re-keyed playerMap ${cleanOld} → ${cleanId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-11
@@ -292,6 +292,11 @@ export default class Player extends EventEmitter {
|
|||||||
connection = null;
|
connection = null;
|
||||||
_guildId = null;
|
_guildId = null;
|
||||||
_channelId = null;
|
_channelId = null;
|
||||||
|
// The channel this player was originally spawned/assigned to for 247 mode.
|
||||||
|
// Set externally by spawnPlayer after joining. Used by _is247Enabled() so
|
||||||
|
// that even if the bot is temporarily in a transit channel (e.g. "move"),
|
||||||
|
// the player knows its intended home channel and can check 247 correctly.
|
||||||
|
_home247Channel = null;
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
queue = null;
|
queue = null;
|
||||||
@@ -413,19 +418,19 @@ export default class Player extends EventEmitter {
|
|||||||
const channels = Array.isArray(raw)
|
const channels = Array.isArray(raw)
|
||||||
? raw.map(id => String(id).replace(/\D/g, "")).filter(Boolean)
|
? raw.map(id => String(id).replace(/\D/g, "")).filter(Boolean)
|
||||||
: [String(raw).replace(/\D/g, "")];
|
: [String(raw).replace(/\D/g, "")];
|
||||||
const currentChannel = String(this._channelId).replace(/\D/g, "");
|
|
||||||
|
|
||||||
// Primary check: current channel is in the 247 list.
|
// Use the home channel this player was assigned to for 247 — this is
|
||||||
if (channels.includes(currentChannel)) return true;
|
// set by spawnPlayer and doesn't change when the bot is temporarily
|
||||||
|
// moved to a transit channel. This gives a per-player 247 check that
|
||||||
|
// works correctly with multi-voice-per-guild setups.
|
||||||
|
const homeChannel = this._home247Channel
|
||||||
|
? String(this._home247Channel).replace(/\D/g, "")
|
||||||
|
: null;
|
||||||
|
const currentChannel = String(this._channelId ?? "").replace(/\D/g, "");
|
||||||
|
|
||||||
// Fallback: if the player is mid-recovery or mid-join, the bot may
|
// Check home channel first (most reliable), then current channel
|
||||||
// temporarily be in a transit channel (e.g. "move") that isn't in the
|
// (covers players created via join command that have no home set).
|
||||||
// 247 list yet. If the guild has ANY 247 channels configured and active,
|
return channels.includes(homeChannel) || channels.includes(currentChannel);
|
||||||
// treat the player as 247 to prevent premature inactivity/alone timers
|
|
||||||
// from firing while the player is still reconnecting to the right channel.
|
|
||||||
if ((this._isRecovering || this._isJoining) && channels.length > 0) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.settingsMgr?.getServer) return checkSettings(this.settingsMgr.getServer(this._guildId));
|
if (this.settingsMgr?.getServer) return checkSettings(this.settingsMgr.getServer(this._guildId));
|
||||||
@@ -513,6 +518,8 @@ export default class Player extends EventEmitter {
|
|||||||
this._isRecovering = false;
|
this._isRecovering = false;
|
||||||
this._recoveryPending = false;
|
this._recoveryPending = false;
|
||||||
this._recoveryAttempts = 0;
|
this._recoveryAttempts = 0;
|
||||||
|
// Keep _home247Channel in sync with the channel we successfully recovered to.
|
||||||
|
if (this._channelId) this._home247Channel = this._channelId;
|
||||||
|
|
||||||
const current = this.queue.getCurrent();
|
const current = this.queue.getCurrent();
|
||||||
if (current) {
|
if (current) {
|
||||||
|
|||||||
Reference in new issue
Block a user