diff --git a/commands/autoplay.mjs b/commands/autoplay.mjs index 4f383c9..4d6f990 100644 --- a/commands/autoplay.mjs +++ b/commands/autoplay.mjs @@ -240,7 +240,6 @@ function pickSerialized(p, ctx, lastTrack) { }; const prev = p._autoplayPickChain ?? Promise.resolve(); const next = prev.then(run, run); - // Keep the chain alive even if a caller lets a rejection slip through. p._autoplayPickChain = next.catch(() => {}); return next; } diff --git a/commands/join.mjs b/commands/join.mjs index 3e10cf5..47f9b34 100644 --- a/commands/join.mjs +++ b/commands/join.mjs @@ -42,7 +42,6 @@ function resolveChannelId(rawArg, ctx, message) { if (mentionMatch) return mentionMatch[2]; if (idMatch) return idMatch[1]; - // Try name-based lookup — use the actual message to resolve the guild ID const guildId = cleanId(getMessageGuildId(message)); if (!guildId) return null; @@ -75,7 +74,6 @@ export async function run(message, data) { return this.players.initPlayer(message, resolvedId); } - // No argument — auto-detect the user's current voice channel const { channelId: cid } = await this.players.checkVoiceChannels(message); if (!cid) { const prefix = this.handler.getPrefix(getMessageGuildId(message)); diff --git a/commands/settings.mjs b/commands/settings.mjs index f2e9ffb..4140ded 100644 --- a/commands/settings.mjs +++ b/commands/settings.mjs @@ -8,7 +8,6 @@ import { CommandBuilder } from "../src/commands/index.mjs"; import { getMessageGuildId } from "../src/ui/index.mjs"; -// kept verbatim from the original file (unused there as well): import { logger } from "../src/core/Logger.mjs"; import { SHORTCUTS, BOOL_SETTINGS, VALID_LOCALES, setValidLocales, diff --git a/commands/settings/channels247.mjs b/commands/settings/channels247.mjs index a417b82..ade11d0 100644 --- a/commands/settings/channels247.mjs +++ b/commands/settings/channels247.mjs @@ -128,8 +128,6 @@ async function enable247(ctx, set, guildId, channelId) { const channels = get247Channels(set); if (channels.has(id)) return; - // Platform only supports 1 voice channel per bot per guild. - // If another channel already has 24/7, disable it first. if (channels.size >= MAX_247_CHANNELS) { for (const oldId of channels) { if (oldId !== id) { diff --git a/shard.mjs b/shard.mjs index 144bb3b..b0d2d51 100644 --- a/shard.mjs +++ b/shard.mjs @@ -99,8 +99,6 @@ const respawn = shardingCfg.respawn !== false; const spawnTimeout = cfgPositiveInt(shardingCfg, "spawnTimeout", 30_000); const spawnDelay = Math.max(0, Number(shardingCfg.spawnDelay) >= 0 ? Number(shardingCfg.spawnDelay) : 5_000); -// Absolute path to the bot entry — robust regardless of cwd (fork resolves -// relative paths against cwd, but the manager may be started from anywhere). const entryFile = fileURLToPath(new URL("./index.mjs", import.meta.url)); const manager = new ShardingManager(entryFile, { diff --git a/src/commands/CommandHandler.mjs b/src/commands/CommandHandler.mjs index b22cb9e..8bc8c89 100644 --- a/src/commands/CommandHandler.mjs +++ b/src/commands/CommandHandler.mjs @@ -286,10 +286,6 @@ export class CommandHandler extends EventEmitter { return this.processCommand(cmd.subcommands[idx], args.slice(1), msg, previous + this.format(" " + cmd.subcommands[idx].name), external); } - // `error === true` → internal invocation: the error reply was already - // sent by _parseOptions and, exactly like the original monolith, the - // command must NOT run (no "run" emission). A string is the external- - // mode error, returned to the caller as before. const { opts, error } = this._parseOptions(cmd, args, msg, previous, external); if (error) return (error === true) ? undefined : error; diff --git a/src/core/Bot.mjs b/src/core/Bot.mjs index 86b1f3b..31a694a 100644 --- a/src/core/Bot.mjs +++ b/src/core/Bot.mjs @@ -139,10 +139,6 @@ class Remix { intentionalLeaveTTL: timers.intentionalLeaveTTL ?? 10_000, }; - // Fluxer 3.0: ClientOptions.presence is the normalized PresenceUpdateOptions - // shape (customStatus/emojiName/emojiId) — the 2.2 wire format - // (custom_status) is no longer read here. buildRuntimePresence() outputs - // exactly the normalized shape, so the initial presence reuses it. const client = new Client({ waitForGuilds: true, cache: { guilds: false, channels: false, users: false, members: false }, @@ -350,11 +346,6 @@ class Remix { logger.commands(`Modules loaded (${succeeded} succeeded, ${failed} failed).`); }); - // Fluxer.js 3.0 sharding (opt-in, root `shard.mjs`): a child forked by a - // ShardingManager attaches the child-side ShardClientUtil BEFORE login — - // it applies FLUXER_SHARD_IDS/FLUXER_SHARD_COUNT to the client options - // and routes IDENTIFYs through the parent's shared per-IP budget — then - // reports readiness so the supervisor's spawn() promise resolves. const startLogin = async () => { if (ShardingUtils.isShardedProcess()) { try { @@ -364,8 +355,7 @@ class Remix { `[Startup] Sharding child attached — ${ShardingUtils.describeSharding(client)}.` ); } catch (e) { - // Fatal: without the shard slice this child would identify as shard 0 - // like every other child and thrash the gateway sessions. + logger.error( "[Startup] FATAL: running under a ShardingManager but the sharding attach failed:", e?.message @@ -402,7 +392,6 @@ class Remix { .filter(id => id.length >= 15 && id.length <= 22); if (cleaned.length > 1) { - // Only 1 channel per guild supported. Keep first, drop the rest. serverSettings.set("stay_247", cleaned.slice(0, 1)); logger.settings( `[settings] Trimmed stay_247 for guild ${guildId}: had ${cleaned.length} channels, kept first 1.` @@ -547,9 +536,6 @@ class Remix { if (shard.ws) attachToSocket(shard.ws, `Shard ${id} socket`); }; - // Fluxer 3.0: the ws manager exposes shards via getShards() (2.2 used a - // `shards` Map property) and a sharded child owns several of them — - // attach to every shard connected in this process, not just shard 0. for (const [id, shard] of ShardingUtils.getLocalShards(this.client)) { attachToShard(shard, id); } @@ -583,7 +569,6 @@ class Remix { } } -// Attach channel/voice operations (spawn, leave, shared servers, helpers). applyMixins(Remix, BotVoiceMixin); export { Remix }; diff --git a/src/core/BotVoiceMixin.mjs b/src/core/BotVoiceMixin.mjs index c243a3e..85e613e 100644 --- a/src/core/BotVoiceMixin.mjs +++ b/src/core/BotVoiceMixin.mjs @@ -158,8 +158,6 @@ const BotVoiceMixin = { markIntentionalLeave(channelId, ttlMs = null) { const cleanChId = cleanId(channelId); if (!cleanChId) return; - // A user-initiated leave must also cancel any rejoin already armed for - // this channel — otherwise the bot would come back 3s after !leave. this.cancel247Rejoin?.(cleanChId); if (ttlMs === null) ttlMs = this.config?.timers?.intentionalLeaveTTL ?? 10_000; const existing = this.intentionalLeaves.get(cleanChId); @@ -191,7 +189,7 @@ const BotVoiceMixin = { } if (!this._247RejoinTimers) this._247RejoinTimers = new Map(); - if (this._247RejoinTimers.has(cleanCh)) return; // already armed — keep the earliest + if (this._247RejoinTimers.has(cleanCh)) return; const delay = delayMs ?? this.config?.timers?.rejoin247Delay ?? 3_000; logger.voice247(`[247] Arming bot-level rejoin for ${cleanCh} (guild ${cleanG}) in ${delay / 1000}s`); @@ -251,9 +249,6 @@ const BotVoiceMixin = { ?? this.players.getPlayerByGuildAndChannel(cleanGuildId, cleanChannelId); if (existing) { if (!isPlayerConnectionDead(existing)) return existing; - // A connection-less zombie (e.g. a 24/7 player whose LiveKit session - // died without a serverLeave reaching us) is worse than useless: it - // blocks rejoins AND swallows !play. Evict it and spawn a live one. logger.voice247( `[_spawnPlayer] Existing player for ${cleanChannelId} has a dead connection — evicting and respawning.` ); diff --git a/src/core/Logger.mjs b/src/core/Logger.mjs index b7b0536..d7906f6 100644 --- a/src/core/Logger.mjs +++ b/src/core/Logger.mjs @@ -66,7 +66,6 @@ function _stormGate(level, tag, args) { const st = _stormGuard.get(key); if (st === undefined) { if (_stormGuard.size >= STORM_MAX_KEYS) { - // Evict the oldest key to bound memory. _stormGuard.delete(_stormGuard.keys().next().value); } _stormGuard.set(key, { n: 0, start: now }); diff --git a/src/dashboard/Dashboard.mjs b/src/dashboard/Dashboard.mjs index be84d54..e401900 100644 --- a/src/dashboard/Dashboard.mjs +++ b/src/dashboard/Dashboard.mjs @@ -234,12 +234,8 @@ class Dashboard { } } -// Attach the split-out concerns: the remote RPC handler methods (runFunction, -// confirmLogin and the authorization helpers) from RpcHandlersMixin. applyMixins(Dashboard, RpcHandlersMixin); -// Re-attach the static conversion helpers (convertUser, convertChannel, -// convertPlayer, …) so external `Dashboard.convertX(...)` call sites keep working. Object.assign(Dashboard, Serializers); export { Dashboard }; diff --git a/src/dashboard/RedisHandler.mjs b/src/dashboard/RedisHandler.mjs index 3403d7d..104c781 100644 --- a/src/dashboard/RedisHandler.mjs +++ b/src/dashboard/RedisHandler.mjs @@ -21,7 +21,7 @@ import { logger } from "../core/Logger.mjs"; * @returns {number} Delay in ms before the next reconnect attempt. */ const DEFAULT_RETRY_STRATEGY = (retries) => { - if (!Number.isFinite(retries)) return 15_000; // defensive: wrong-shape argument + if (!Number.isFinite(retries)) return 15_000; return retries < 10 ? Math.min(retries * 500, 5_000) : 15_000; }; @@ -49,8 +49,6 @@ export class RedisHandler { constructor(opts = {}) { this.platform = opts.platform ?? "fluxer"; - // `url` (and any explicit socket options) come from config; the retry - // strategy is always pinned so misconfig can never cause a hot retry loop. const { platform: _platform, ...clientOpts } = { ...opts }; clientOpts.socket = { ...(clientOpts.socket ?? {}), @@ -77,9 +75,6 @@ export class RedisHandler { * @async */ async _connect() { - // Connect both clients CONCURRENTLY. The previous sequential awaits made - // the subscriber wait behind the main client's retry loop: while Redis was - // down, the subscriber never even attempted to connect. this.client.connect() .then(() => { if (this._destroyed) return; @@ -183,8 +178,6 @@ export class RedisHandler { this._destroyed = true; if (this._pingInterval) { clearInterval(this._pingInterval); this._pingInterval = null; } if (this._readyTimer) { clearTimeout(this._readyTimer); this._readyTimer = null; } - // quit() waits for a live connection; on a still-connecting/down client it - // would pend forever (bot shutdown hang). Hard-disconnect instead. try { if (this.subscriber?.isReady) await this.subscriber.quit(); else this.subscriber?.disconnect(); diff --git a/src/music/LavalinkManager.mjs b/src/music/LavalinkManager.mjs index cb60ca1..f4ca57d 100644 --- a/src/music/LavalinkManager.mjs +++ b/src/music/LavalinkManager.mjs @@ -179,8 +179,6 @@ export class LavalinkManager extends EventEmitter { } } - // Fluxer 3.0 sharding: gateway payloads are guild-scoped — route to the - // shard that owns this guild (single process: always shard 0, as before). const targetShardId = ShardingUtils.shardIdForGuild(this._client, guildId); if (typeof this._client?.ws?.send === "function") { @@ -211,16 +209,12 @@ export class LavalinkManager extends EventEmitter { const attachRawWs = () => { try { - // Fluxer 3.0 + sharding: getShards() replaces the 2.2 `shards` Map - // property, and a sharded child owns several shards — track the raw - // socket of EVERY local shard, not just shard 0. const wsObjs = ShardingUtils.localShardSockets(client); if (wsObjs.length === 0) return; if (!this._rawWsObjs) this._rawWsObjs = new Set(); const attached = this._rawWsObjs; - // Detach listeners from sockets that went away (reconnects). for (const old of attached) { if (wsObjs.includes(old)) continue; try { @@ -246,7 +240,6 @@ export class LavalinkManager extends EventEmitter { attached.delete(old); } - // Create the shared handlers once (stateless parsers). if (!this._rawWsHandler) { const botId = this._client?.user?.id; let _vsuLogCooldown = 0; @@ -319,7 +312,6 @@ export class LavalinkManager extends EventEmitter { attached.add(wsObj); } - // Legacy singular field kept in sync (first socket). this._rawWsObj = wsObjs[0] ?? null; } catch (e) { logger.warn("[LavalinkManager] Raw WS setup error:", e.message); diff --git a/src/music/PlayerEventsMixin.mjs b/src/music/PlayerEventsMixin.mjs index ba1e104..00a7a56 100644 --- a/src/music/PlayerEventsMixin.mjs +++ b/src/music/PlayerEventsMixin.mjs @@ -14,10 +14,6 @@ import { cleanId } from "../utils/Utils.mjs"; import { getMessageGuildId } from "../ui/index.mjs"; import { Dashboard } from "../dashboard/Dashboard.mjs"; -// Module-level ID helpers from the original PlayerManager.mjs. They live in -// this module (not the base file) because it is the shared leaf of the three -// PlayerManager modules, which keeps the import graph acyclic: -// PlayerManager.mjs → PlayerEventsMixin.mjs ← PlayerLifecycleMixin.mjs. /** @private @param {Player} player @param {object|null} [fallbackChannel=null] @returns {string} Cleaned guild ID. */ function getPlayerGuildId(player, fallbackChannel = null) { return cleanId( diff --git a/src/music/PlayerLifecycleMixin.mjs b/src/music/PlayerLifecycleMixin.mjs index aca3649..e1a5e48 100644 --- a/src/music/PlayerLifecycleMixin.mjs +++ b/src/music/PlayerLifecycleMixin.mjs @@ -21,8 +21,6 @@ import { getGlobalColor, getMessageGuildId } from "../ui/index.mjs"; import { hasHumansInChannel, iterateVoiceStates } from "../voice/VoiceStateResolver.mjs"; import { getPlayerChannelId } from "./PlayerEventsMixin.mjs"; -// Module-level join/permission helpers from the original PlayerManager.mjs -// (only initPlayer below uses them, so they stay private to this module). /** @private Check whether the bot has required voice permissions in a channel. @param {object} client @param {string} channelId @returns {boolean} True if the bot can connect, speak, and use VAD. */ function botHasVoicePermissions(client, channelId) { try { @@ -297,9 +295,6 @@ const PlayerLifecycleMixin = { ?? this.getPlayerByChannelId(cleanChannelId); if (existing) { if (isPlayerConnectionDead(existing)) { - // Zombie in the map (e.g. 24/7 player whose voice session died): - // returning it would make !play silently do nothing. Evict it and - // fall through to spawn a fresh live player. logger.voice247( `[PlayerManager] Existing player for ${cleanChannelId} has a dead connection — evicting before initPlayer.` ); diff --git a/src/music/PlayerManager.mjs b/src/music/PlayerManager.mjs index 00b0898..29112a4 100644 --- a/src/music/PlayerManager.mjs +++ b/src/music/PlayerManager.mjs @@ -224,6 +224,4 @@ export class PlayerManager { } -// Attach the split-out concerns: dashboard event wiring (PlayerEventsMixin) -// and voice-channel detection / player lifecycle (PlayerLifecycleMixin). applyMixins(PlayerManager, PlayerEventsMixin, PlayerLifecycleMixin); diff --git a/src/music/audio/FluxerAudioBridge.mjs b/src/music/audio/FluxerAudioBridge.mjs index fc31593..39bf974 100644 --- a/src/music/audio/FluxerAudioBridge.mjs +++ b/src/music/audio/FluxerAudioBridge.mjs @@ -414,6 +414,4 @@ export class FluxerAudioBridge extends EventEmitter { } } -// Attach the split-out concerns: stream pipeline building/routing -// (StreamPipeline) and Lavalink REST HTTP helpers (HttpStreams). applyMixins(FluxerAudioBridge, StreamPipeline, HttpStreams); diff --git a/src/music/player/PlaybackMixin.mjs b/src/music/player/PlaybackMixin.mjs index f89bf11..6a04cf5 100644 --- a/src/music/player/PlaybackMixin.mjs +++ b/src/music/player/PlaybackMixin.mjs @@ -309,7 +309,6 @@ const PlaybackMixin = { if (result === "finished" && !this._skipping && !this.leaving && !this._paused) { this._handleTrackEnd(); } else if (result === "stopped") { - // Stopped intentionally (skip/seek/stop) — nothing to do. } }, diff --git a/src/music/player/Player.mjs b/src/music/player/Player.mjs index 5245e4b..6de05fc 100644 --- a/src/music/player/Player.mjs +++ b/src/music/player/Player.mjs @@ -339,20 +339,12 @@ class Player extends EventEmitter { return; } - // 1) Detach from playerMap (active + home keys) so rejoin paths no - // longer see a "player already here" and skip. detachPlayerFromManager(ctx, this, channelId); - // 2) Arm the ctx-level rejoin BEFORE destroying ourselves — the timer - // must outlive this instance. ctx.schedule247Rejoin(channelId, guildId); - // 3) Notify (dashboard close/stopplay); the manager-level autoleave - // listeners suppress the actual leave for 24/7 channels, so this is - // notification-only. this.emit("autoleave"); - // 4) Finally destroy the dead instance. this.destroy(); } @@ -510,14 +502,6 @@ class Player extends EventEmitter { this._assertSelfDeaf(vm, channelId); if (typeof voiceConn.on === "function") { - // Self-deaf keeper: Fluxer's VoiceManager answers every - // requestVoiceStateSync event (emitted by conn.stop()/stopVideo(), - // which the audio bridge triggers on EVERY play() and stop()) with a - // gateway VoiceStateUpdate that resets self_deaf to false — silently - // un-deafening the bot the moment the first track starts and again on - // every skip/stop/track-end. The manager registers its own sync - // listener inside registerConnection() (before join() resolved), so - // this listener runs AFTER it and our re-deafen state update wins. voiceConn.on("requestVoiceStateSync", () => { if (this.leaving || this._destroyed) return; this._assertSelfDeaf(vm, channelId); @@ -536,11 +520,6 @@ class Player extends EventEmitter { const gId = cleanId(this._guildId ?? ""); if (mode === "on" && cId && gId) { - // 24/7: the voice session is gone but the commitment stands. - // Detach this now-dead player (a zombie in the map makes every - // rejoin path bail with "already has a player"), arm a - // bot-level rejoin that survives our own destroy, notify, then - // destroy ourselves. logger.player("[Player] serverLeave in 24/7 mode — detaching and scheduling rejoin"); this._detachAndSchedule247Rejoin(cId, gId); } else { @@ -981,8 +960,6 @@ class Player extends EventEmitter { } } -// Attach the split-out concerns: playback advancement (PlaybackMixin), search -// & queue-filling (SearchMixin), and user-facing rendering (DisplayMixin). applyMixins(Player, PlaybackMixin, SearchMixin, DisplayMixin); export { Player as default, Player, Queue }; diff --git a/src/music/player/SearchMixin.mjs b/src/music/player/SearchMixin.mjs index bf9140d..b8ac401 100644 --- a/src/music/player/SearchMixin.mjs +++ b/src/music/player/SearchMixin.mjs @@ -229,11 +229,6 @@ const SearchMixin = { if (!isUrl) throw searchErr; } let lcTracks = result?.tracks ?? []; - // Set when the only results we have came from the oEmbed title-search - // fallback. That path resolves a SINGLE video (direct URL load was - // bot-blocked), so its result list is a search page — NOT a playlist. - // Bulk-queueing it would queue a bunch of "related" songs instead of - // the one requested video (original fluxer bug reported by users). let fromTitleFallback = false; if (isUrl && lcTracks.length === 0 && ytId) { @@ -288,9 +283,6 @@ const SearchMixin = { return; } - // Pick the track to queue. For a title-search fallback, prefer the - // result that is the exact video the user requested (search may rank - // covers/remixes first); otherwise take the first result. let firstTrack = lcTracks[0]; if (fromTitleFallback && ytId) { firstTrack = lcTracks.find(t => (t?.info?.identifier ?? t?.identifier) === ytId) ?? lcTracks[0]; @@ -299,8 +291,6 @@ const SearchMixin = { } } - // Only a genuine playlist/mix URL load may bulk-queue. A title-search - // fallback for a single video must queue exactly one track. if (isUrl && !fromTitleFallback && lcTracks.length > 1) { const videos = lcTracks.map(t => this._lcTrackToVideo(t, trackMeta)).filter(Boolean); this.addManyToQueue(videos, top); diff --git a/src/services/lastfm/LastFmManager.mjs b/src/services/lastfm/LastFmManager.mjs index 2ff94c1..c885886 100644 --- a/src/services/lastfm/LastFmManager.mjs +++ b/src/services/lastfm/LastFmManager.mjs @@ -275,13 +275,6 @@ export class LastFmManager { } } -// Attach the split-out concerns: user-session storage (UserStoreMixin), -// scrobbling (ScrobblingMixin), track/artist/album/tag queries -// (TrackQueriesMixin), per-user chart queries (UserQueriesMixin) and -// server/guild statistics (ServerStatsMixin). applyMixins(LastFmManager, UserStoreMixin, ScrobblingMixin, TrackQueriesMixin, UserQueriesMixin, ServerStatsMixin); -// Keep the old import surface: commands used to import the URL helpers from -// this module when it was a single file. (The class itself is exported by its -// declaration above.) export { parseLastFmUrl, isLastFmUrl } from "./urlUtils.mjs"; diff --git a/src/ui/MessageHandler.mjs b/src/ui/MessageHandler.mjs index 0a83a80..f278dde 100644 --- a/src/ui/MessageHandler.mjs +++ b/src/ui/MessageHandler.mjs @@ -558,19 +558,13 @@ export class MessageHandler { const { getVoiceManager } = await import("@fluxerjs/voice"); const channel = await this.client.channels.fetch(channelId).catch(() => null); if (!channel) throw new Error("Voice channel not found."); - // Fluxer 3.0: isGuild() is ChannelType-based and replaces the 2.2 - // 'guildId' own-property duck check; the fallback keeps custom/stub - // channel objects working. + const isGuildChannel = channel.isGuild?.() ?? ("guildId" in channel); if (!isGuildChannel) throw new Error("Cannot join a non-guild voice channel."); const vm = getVoiceManager(this.client); if (!vm) throw new Error("VoiceManager not available."); const voiceConn = await vm.join(channel); - // Self-deafen raw joins too (Player.join does this for playback - // sessions): a music bot never listens, and Fluxer's VoiceManager resets - // self_deaf on every requestVoiceStateSync (fired by conn.stop()) — the - // re-assert listener keeps the deafened state for the connection's - // lifetime. Best effort: updateVoiceState no-ops without connection_id. + const deafen = () => { try { vm.updateVoiceState(channel.id, { self_deaf: true, self_mute: false }); diff --git a/src/ui/Paginators.mjs b/src/ui/Paginators.mjs index 2390573..883dbba 100644 --- a/src/ui/Paginators.mjs +++ b/src/ui/Paginators.mjs @@ -346,7 +346,6 @@ export class QueuePaginator { try { await rawMsg.removeAllReactions(); } catch (e) { - // Message deleted — nothing left to clean up. if (String(e?.message ?? e).includes("Message wasn't found") || e?.code === 10008) return; for (const emoji of [prev, next]) { try { diff --git a/src/utils/Helpers247.mjs b/src/utils/Helpers247.mjs index fa37269..d607fab 100644 --- a/src/utils/Helpers247.mjs +++ b/src/utils/Helpers247.mjs @@ -65,14 +65,12 @@ export function get247ChannelMode(set, channelId) { * Original GatewayHandler.mjs and index.mjs still import this. */ export function remove247ChannelMode(set, channelId, currentChannels) { - // No-op: modes no longer exist, stay_247 array is managed directly. } /** * No-op: per-channel modes removed. Kept for backward compatibility. */ export function set247ChannelMode(set, channelId, mode) { - // No-op: modes no longer exist. } /** diff --git a/src/utils/ShardingUtils.mjs b/src/utils/ShardingUtils.mjs index d6de39e..90e2753 100644 --- a/src/utils/ShardingUtils.mjs +++ b/src/utils/ShardingUtils.mjs @@ -51,7 +51,6 @@ export function shardIdForGuild(client, guildId) { if (Number.isInteger(id) && id >= 0) return id; } } catch { - // fall through to the single-process default } return 0; } @@ -74,7 +73,6 @@ export function getLocalShards(client) { return [...map.entries()].filter(([id]) => Number.isInteger(id)); } } catch { - // Fluxer 3.0: client.ws throws before login — treat as "no shards yet". } return []; } diff --git a/src/voice/gateway/GatewayHandler.mjs b/src/voice/gateway/GatewayHandler.mjs index a41f352..129f701 100644 --- a/src/voice/gateway/GatewayHandler.mjs +++ b/src/voice/gateway/GatewayHandler.mjs @@ -117,15 +117,11 @@ class GatewayHandler { const client = remix.client; try { - // Fluxer 3.0 + sharding: the ws manager exposes shards via getShards() - // (2.2 used a `shards` Map property) and a sharded child owns several - // shards — track the raw socket of EVERY local shard, not just shard 0. const wsObjs = ShardingUtils.localShardSockets(client); if (!remix._rawGatewayWsObjs) remix._rawGatewayWsObjs = new Set(); const attached = remix._rawGatewayWsObjs; - // Detach listeners from sockets that went away (reconnects). for (const old of attached) { if (wsObjs.includes(old)) continue; try { @@ -142,8 +138,6 @@ class GatewayHandler { let attachedNew = false; - // Create the shared raw-socket handlers once (stateless parsers - // shared by every local shard socket). if (!remix._rawGatewayHandler) { remix._rawGatewayHandler = (data) => { try { @@ -249,7 +243,6 @@ class GatewayHandler { attachedNew = true; } - // Legacy singular field kept in sync (first socket) for compatibility. remix._rawGatewayWsObj = wsObjs[0] ?? null; this.wsListenerAttached = attached.size > 0; if (attachedNew) { @@ -294,12 +287,6 @@ class GatewayHandler { }]; } - // Fluxer 3.0: client.ws is a throwing getter when the gateway is not - // connected (2.2 exposed a plain optional). The raw opcode-3 payload - // below stays in wire format (custom_status) because it bypasses - // ClientUser.setPresence() and hits the shard directly. - // Sharded children fan the update out to every gateway shard in this - // process (presence is per shard); single process = shard 0 as before. try { if (client.ws?.send) { for (const id of ShardingUtils.localShardIds(client)) { @@ -596,8 +583,6 @@ class GatewayHandler { } } -// Attach the split-out concerns: voice-state routing (VoiceStateRouting), -// guild sync & seeding (GuildSync), and 24/7 rejoin management (RejoinManager). applyMixins(GatewayHandler, VoiceStateRouting, GuildSync, RejoinManager); export { GatewayHandler }; diff --git a/src/voice/gateway/RejoinManager.mjs b/src/voice/gateway/RejoinManager.mjs index e64af6a..8749a3a 100644 --- a/src/voice/gateway/RejoinManager.mjs +++ b/src/voice/gateway/RejoinManager.mjs @@ -91,10 +91,6 @@ const RejoinManager = { this._rejoinAttempts.delete(cleanChannelId); return; } - // Ghost/zombie player: object alive in the map but its voice session - // is long gone (serverLeave / dead socket). It used to block this - // rejoin with "already has a player" — the #1 reason 24/7 silently - // died. Evict it and respawn a live connection. logger.voice247( `[Rejoin] Existing player for ${cleanChannelId} has a dead connection — evicting before rejoin.` ); diff --git a/src/voice/gateway/VoiceStateRouting.mjs b/src/voice/gateway/VoiceStateRouting.mjs index 963346c..743f670 100644 --- a/src/voice/gateway/VoiceStateRouting.mjs +++ b/src/voice/gateway/VoiceStateRouting.mjs @@ -271,7 +271,6 @@ const VoiceStateRouting = { const guildId = vsuGuildId; if (newChannelId && guildId && oldChannelId && oldChannelId !== newChannelId) { - // During boot recovery, ignore move events — the recovery loop handles rejoining. if (this._bootRecoveryActive) { logger.voice247( `[247] Ignoring bot move ${cleanId(oldChannelId)} → ${cleanId(newChannelId)} during boot recovery.` @@ -282,7 +281,6 @@ const VoiceStateRouting = { const cleanNew = cleanId(newChannelId); const cleanOld = cleanId(oldChannelId); - // Check if old channel is a saved 24/7 channel const oldIs247 = (() => { try { const set = remix.settingsMgr.getServer(guildId); @@ -290,7 +288,6 @@ const VoiceStateRouting = { } catch (_) { return false; } })(); - // Check if new channel is a saved 24/7 channel or has a pending spawn const newChannelSaved = (() => { try { const set = remix.settingsMgr.getServer(guildId); @@ -302,9 +299,6 @@ const VoiceStateRouting = { const existingPlayer = remix.players.playerMap.get(cleanOld); if (oldIs247 && existingPlayer) { - // Old channel is 24/7 — bot physically moved away, so the voice - // connection to old channel is dead. Destroy the old player and - // schedule a fresh rejoin so it gets a new live connection. logger.voice247( `[247] Bot moved away from 24/7 channel ${cleanOld} → ${cleanNew}. ` + `Destroying stale player, scheduling rejoin for ${cleanOld}.` @@ -324,13 +318,11 @@ const VoiceStateRouting = { }, rejoinDelay); } } else if (newChannelSaved || newChannelPendingSpawn) { - // New channel is already 24/7 or being spawned — keep both, don't rekey. logger.voice247( `[247] Keeping both channels ${cleanOld} and ${cleanNew} ` + `(saved=${newChannelSaved} pending=${newChannelPendingSpawn})` ); } else if (existingPlayer && cleanNew !== cleanOld) { - // Neither channel is 24/7 — safe to rekey the player. const targetChannel = client.channels.get(cleanNew) ?? client.channels.get?.(cleanNew) ?? null; @@ -351,8 +343,6 @@ const VoiceStateRouting = { } } - // Simplified 24/7: stay_247 list only changes via !247 command. - // Do NOT auto-add/remove channels on bot move. } catch (e) { logger.warn("[247] Bot move handler failed:", e.message); } @@ -375,11 +365,6 @@ const VoiceStateRouting = { return; } - // Player missing or already dead. The old code just dropped the - // event ("deferring until grace period ends" — nothing ever - // replayed it), so a 24/7 channel killed during boot never came - // back. Arm a deferred bot-level rejoin for just after the grace - // window instead. const graceSet = remix.settingsMgr.getServer(guildId); const graceMode = graceSet ? get247ChannelMode(graceSet, cleanOld) : "off"; if (graceMode === "on" && typeof remix.schedule247Rejoin === "function") {