This commit is contained in:
NoLogicAlan committed 2026-09-10 03:02:51 +03:00
1 parent 35aab94a53
commit 3ef54117bb
27 files changed
+5 -156

No files matched your search

-1
View File
@@ -240,7 +240,6 @@ function pickSerialized(p, ctx, lastTrack) {
}; };
const prev = p._autoplayPickChain ?? Promise.resolve(); const prev = p._autoplayPickChain ?? Promise.resolve();
const next = prev.then(run, run); const next = prev.then(run, run);
// Keep the chain alive even if a caller lets a rejection slip through.
p._autoplayPickChain = next.catch(() => {}); p._autoplayPickChain = next.catch(() => {});
return next; return next;
} }
-2
View File
@@ -42,7 +42,6 @@ function resolveChannelId(rawArg, ctx, message) {
if (mentionMatch) return mentionMatch[2]; if (mentionMatch) return mentionMatch[2];
if (idMatch) return idMatch[1]; if (idMatch) return idMatch[1];
// Try name-based lookup — use the actual message to resolve the guild ID
const guildId = cleanId(getMessageGuildId(message)); const guildId = cleanId(getMessageGuildId(message));
if (!guildId) return null; if (!guildId) return null;
@@ -75,7 +74,6 @@ export async function run(message, data) {
return this.players.initPlayer(message, resolvedId); return this.players.initPlayer(message, resolvedId);
} }
// No argument — auto-detect the user's current voice channel
const { channelId: cid } = await this.players.checkVoiceChannels(message); const { channelId: cid } = await this.players.checkVoiceChannels(message);
if (!cid) { if (!cid) {
const prefix = this.handler.getPrefix(getMessageGuildId(message)); const prefix = this.handler.getPrefix(getMessageGuildId(message));
-1
View File
@@ -8,7 +8,6 @@
import { CommandBuilder } from "../src/commands/index.mjs"; import { CommandBuilder } from "../src/commands/index.mjs";
import { getMessageGuildId } from "../src/ui/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 { logger } from "../src/core/Logger.mjs";
import { import {
SHORTCUTS, BOOL_SETTINGS, VALID_LOCALES, setValidLocales, SHORTCUTS, BOOL_SETTINGS, VALID_LOCALES, setValidLocales,
-2
View File
@@ -128,8 +128,6 @@ async function enable247(ctx, set, guildId, channelId) {
const channels = get247Channels(set); const channels = get247Channels(set);
if (channels.has(id)) return; 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) { if (channels.size >= MAX_247_CHANNELS) {
for (const oldId of channels) { for (const oldId of channels) {
if (oldId !== id) { if (oldId !== id) {
-2
View File
@@ -99,8 +99,6 @@ const respawn = shardingCfg.respawn !== false;
const spawnTimeout = cfgPositiveInt(shardingCfg, "spawnTimeout", 30_000); const spawnTimeout = cfgPositiveInt(shardingCfg, "spawnTimeout", 30_000);
const spawnDelay = Math.max(0, Number(shardingCfg.spawnDelay) >= 0 ? Number(shardingCfg.spawnDelay) : 5_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 entryFile = fileURLToPath(new URL("./index.mjs", import.meta.url));
const manager = new ShardingManager(entryFile, { const manager = new ShardingManager(entryFile, {
-4
View File
@@ -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); 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); const { opts, error } = this._parseOptions(cmd, args, msg, previous, external);
if (error) return (error === true) ? undefined : error; if (error) return (error === true) ? undefined : error;
+1 -16
View File
@@ -139,10 +139,6 @@ class Remix {
intentionalLeaveTTL: timers.intentionalLeaveTTL ?? 10_000, 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({ const client = new Client({
waitForGuilds: true, waitForGuilds: true,
cache: { guilds: false, channels: false, users: false, members: false }, cache: { guilds: false, channels: false, users: false, members: false },
@@ -350,11 +346,6 @@ class Remix {
logger.commands(`Modules loaded (${succeeded} succeeded, ${failed} failed).`); 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 () => { const startLogin = async () => {
if (ShardingUtils.isShardedProcess()) { if (ShardingUtils.isShardedProcess()) {
try { try {
@@ -364,8 +355,7 @@ class Remix {
`[Startup] Sharding child attached — ${ShardingUtils.describeSharding(client)}.` `[Startup] Sharding child attached — ${ShardingUtils.describeSharding(client)}.`
); );
} catch (e) { } 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( logger.error(
"[Startup] FATAL: running under a ShardingManager but the sharding attach failed:", "[Startup] FATAL: running under a ShardingManager but the sharding attach failed:",
e?.message e?.message
@@ -402,7 +392,6 @@ class Remix {
.filter(id => id.length >= 15 && id.length <= 22); .filter(id => id.length >= 15 && id.length <= 22);
if (cleaned.length > 1) { if (cleaned.length > 1) {
// Only 1 channel per guild supported. Keep first, drop the rest.
serverSettings.set("stay_247", cleaned.slice(0, 1)); serverSettings.set("stay_247", cleaned.slice(0, 1));
logger.settings( logger.settings(
`[settings] Trimmed stay_247 for guild ${guildId}: had ${cleaned.length} channels, kept first 1.` `[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`); 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)) { for (const [id, shard] of ShardingUtils.getLocalShards(this.client)) {
attachToShard(shard, id); attachToShard(shard, id);
} }
@@ -583,7 +569,6 @@ class Remix {
} }
} }
// Attach channel/voice operations (spawn, leave, shared servers, helpers).
applyMixins(Remix, BotVoiceMixin); applyMixins(Remix, BotVoiceMixin);
export { Remix }; export { Remix };
+1 -6
View File
@@ -158,8 +158,6 @@ const BotVoiceMixin = {
markIntentionalLeave(channelId, ttlMs = null) { markIntentionalLeave(channelId, ttlMs = null) {
const cleanChId = cleanId(channelId); const cleanChId = cleanId(channelId);
if (!cleanChId) return; 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); this.cancel247Rejoin?.(cleanChId);
if (ttlMs === null) ttlMs = this.config?.timers?.intentionalLeaveTTL ?? 10_000; if (ttlMs === null) ttlMs = this.config?.timers?.intentionalLeaveTTL ?? 10_000;
const existing = this.intentionalLeaves.get(cleanChId); const existing = this.intentionalLeaves.get(cleanChId);
@@ -191,7 +189,7 @@ const BotVoiceMixin = {
} }
if (!this._247RejoinTimers) this._247RejoinTimers = new Map(); 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; const delay = delayMs ?? this.config?.timers?.rejoin247Delay ?? 3_000;
logger.voice247(`[247] Arming bot-level rejoin for ${cleanCh} (guild ${cleanG}) in ${delay / 1000}s`); 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); ?? this.players.getPlayerByGuildAndChannel(cleanGuildId, cleanChannelId);
if (existing) { if (existing) {
if (!isPlayerConnectionDead(existing)) return 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( logger.voice247(
`[_spawnPlayer] Existing player for ${cleanChannelId} has a dead connection — evicting and respawning.` `[_spawnPlayer] Existing player for ${cleanChannelId} has a dead connection — evicting and respawning.`
); );
-1
View File
@@ -66,7 +66,6 @@ function _stormGate(level, tag, args) {
const st = _stormGuard.get(key); const st = _stormGuard.get(key);
if (st === undefined) { if (st === undefined) {
if (_stormGuard.size >= STORM_MAX_KEYS) { if (_stormGuard.size >= STORM_MAX_KEYS) {
// Evict the oldest key to bound memory.
_stormGuard.delete(_stormGuard.keys().next().value); _stormGuard.delete(_stormGuard.keys().next().value);
} }
_stormGuard.set(key, { n: 0, start: now }); _stormGuard.set(key, { n: 0, start: now });
-4
View File
@@ -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); applyMixins(Dashboard, RpcHandlersMixin);
// Re-attach the static conversion helpers (convertUser, convertChannel,
// convertPlayer, …) so external `Dashboard.convertX(...)` call sites keep working.
Object.assign(Dashboard, Serializers); Object.assign(Dashboard, Serializers);
export { Dashboard }; export { Dashboard };
+1 -8
View File
@@ -21,7 +21,7 @@ import { logger } from "../core/Logger.mjs";
* @returns {number} Delay in ms before the next reconnect attempt. * @returns {number} Delay in ms before the next reconnect attempt.
*/ */
const DEFAULT_RETRY_STRATEGY = (retries) => { 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; return retries < 10 ? Math.min(retries * 500, 5_000) : 15_000;
}; };
@@ -49,8 +49,6 @@ export class RedisHandler {
constructor(opts = {}) { constructor(opts = {}) {
this.platform = opts.platform ?? "fluxer"; 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 }; const { platform: _platform, ...clientOpts } = { ...opts };
clientOpts.socket = { clientOpts.socket = {
...(clientOpts.socket ?? {}), ...(clientOpts.socket ?? {}),
@@ -77,9 +75,6 @@ export class RedisHandler {
* @async * @async
*/ */
async _connect() { 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() this.client.connect()
.then(() => { .then(() => {
if (this._destroyed) return; if (this._destroyed) return;
@@ -183,8 +178,6 @@ export class RedisHandler {
this._destroyed = true; this._destroyed = true;
if (this._pingInterval) { clearInterval(this._pingInterval); this._pingInterval = null; } if (this._pingInterval) { clearInterval(this._pingInterval); this._pingInterval = null; }
if (this._readyTimer) { clearTimeout(this._readyTimer); this._readyTimer = 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 { try {
if (this.subscriber?.isReady) await this.subscriber.quit(); if (this.subscriber?.isReady) await this.subscriber.quit();
else this.subscriber?.disconnect(); else this.subscriber?.disconnect();
-8
View File
@@ -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); const targetShardId = ShardingUtils.shardIdForGuild(this._client, guildId);
if (typeof this._client?.ws?.send === "function") { if (typeof this._client?.ws?.send === "function") {
@@ -211,16 +209,12 @@ export class LavalinkManager extends EventEmitter {
const attachRawWs = () => { const attachRawWs = () => {
try { 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); const wsObjs = ShardingUtils.localShardSockets(client);
if (wsObjs.length === 0) return; if (wsObjs.length === 0) return;
if (!this._rawWsObjs) this._rawWsObjs = new Set(); if (!this._rawWsObjs) this._rawWsObjs = new Set();
const attached = this._rawWsObjs; const attached = this._rawWsObjs;
// Detach listeners from sockets that went away (reconnects).
for (const old of attached) { for (const old of attached) {
if (wsObjs.includes(old)) continue; if (wsObjs.includes(old)) continue;
try { try {
@@ -246,7 +240,6 @@ export class LavalinkManager extends EventEmitter {
attached.delete(old); attached.delete(old);
} }
// Create the shared handlers once (stateless parsers).
if (!this._rawWsHandler) { if (!this._rawWsHandler) {
const botId = this._client?.user?.id; const botId = this._client?.user?.id;
let _vsuLogCooldown = 0; let _vsuLogCooldown = 0;
@@ -319,7 +312,6 @@ export class LavalinkManager extends EventEmitter {
attached.add(wsObj); attached.add(wsObj);
} }
// Legacy singular field kept in sync (first socket).
this._rawWsObj = wsObjs[0] ?? null; this._rawWsObj = wsObjs[0] ?? null;
} catch (e) { } catch (e) {
logger.warn("[LavalinkManager] Raw WS setup error:", e.message); logger.warn("[LavalinkManager] Raw WS setup error:", e.message);
-4
View File
@@ -14,10 +14,6 @@ import { cleanId } from "../utils/Utils.mjs";
import { getMessageGuildId } from "../ui/index.mjs"; import { getMessageGuildId } from "../ui/index.mjs";
import { Dashboard } from "../dashboard/Dashboard.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. */ /** @private @param {Player} player @param {object|null} [fallbackChannel=null] @returns {string} Cleaned guild ID. */
function getPlayerGuildId(player, fallbackChannel = null) { function getPlayerGuildId(player, fallbackChannel = null) {
return cleanId( return cleanId(
-5
View File
@@ -21,8 +21,6 @@ import { getGlobalColor, getMessageGuildId } from "../ui/index.mjs";
import { hasHumansInChannel, iterateVoiceStates } from "../voice/VoiceStateResolver.mjs"; import { hasHumansInChannel, iterateVoiceStates } from "../voice/VoiceStateResolver.mjs";
import { getPlayerChannelId } from "./PlayerEventsMixin.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. */ /** @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) { function botHasVoicePermissions(client, channelId) {
try { try {
@@ -297,9 +295,6 @@ const PlayerLifecycleMixin = {
?? this.getPlayerByChannelId(cleanChannelId); ?? this.getPlayerByChannelId(cleanChannelId);
if (existing) { if (existing) {
if (isPlayerConnectionDead(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( logger.voice247(
`[PlayerManager] Existing player for ${cleanChannelId} has a dead connection — evicting before initPlayer.` `[PlayerManager] Existing player for ${cleanChannelId} has a dead connection — evicting before initPlayer.`
); );
-2
View File
@@ -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); applyMixins(PlayerManager, PlayerEventsMixin, PlayerLifecycleMixin);
-2
View File
@@ -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); applyMixins(FluxerAudioBridge, StreamPipeline, HttpStreams);
-1
View File
@@ -309,7 +309,6 @@ const PlaybackMixin = {
if (result === "finished" && !this._skipping && !this.leaving && !this._paused) { if (result === "finished" && !this._skipping && !this.leaving && !this._paused) {
this._handleTrackEnd(); this._handleTrackEnd();
} else if (result === "stopped") { } else if (result === "stopped") {
// Stopped intentionally (skip/seek/stop) — nothing to do.
} }
}, },
-23
View File
@@ -339,20 +339,12 @@ class Player extends EventEmitter {
return; return;
} }
// 1) Detach from playerMap (active + home keys) so rejoin paths no
// longer see a "player already here" and skip.
detachPlayerFromManager(ctx, this, channelId); detachPlayerFromManager(ctx, this, channelId);
// 2) Arm the ctx-level rejoin BEFORE destroying ourselves — the timer
// must outlive this instance.
ctx.schedule247Rejoin(channelId, guildId); 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"); this.emit("autoleave");
// 4) Finally destroy the dead instance.
this.destroy(); this.destroy();
} }
@@ -510,14 +502,6 @@ class Player extends EventEmitter {
this._assertSelfDeaf(vm, channelId); this._assertSelfDeaf(vm, channelId);
if (typeof voiceConn.on === "function") { 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", () => { voiceConn.on("requestVoiceStateSync", () => {
if (this.leaving || this._destroyed) return; if (this.leaving || this._destroyed) return;
this._assertSelfDeaf(vm, channelId); this._assertSelfDeaf(vm, channelId);
@@ -536,11 +520,6 @@ class Player extends EventEmitter {
const gId = cleanId(this._guildId ?? ""); const gId = cleanId(this._guildId ?? "");
if (mode === "on" && cId && gId) { 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"); logger.player("[Player] serverLeave in 24/7 mode — detaching and scheduling rejoin");
this._detachAndSchedule247Rejoin(cId, gId); this._detachAndSchedule247Rejoin(cId, gId);
} else { } 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); applyMixins(Player, PlaybackMixin, SearchMixin, DisplayMixin);
export { Player as default, Player, Queue }; export { Player as default, Player, Queue };
-10
View File
@@ -229,11 +229,6 @@ const SearchMixin = {
if (!isUrl) throw searchErr; if (!isUrl) throw searchErr;
} }
let lcTracks = result?.tracks ?? []; 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; let fromTitleFallback = false;
if (isUrl && lcTracks.length === 0 && ytId) { if (isUrl && lcTracks.length === 0 && ytId) {
@@ -288,9 +283,6 @@ const SearchMixin = {
return; 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]; let firstTrack = lcTracks[0];
if (fromTitleFallback && ytId) { if (fromTitleFallback && ytId) {
firstTrack = lcTracks.find(t => (t?.info?.identifier ?? t?.identifier) === ytId) ?? lcTracks[0]; 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) { if (isUrl && !fromTitleFallback && lcTracks.length > 1) {
const videos = lcTracks.map(t => this._lcTrackToVideo(t, trackMeta)).filter(Boolean); const videos = lcTracks.map(t => this._lcTrackToVideo(t, trackMeta)).filter(Boolean);
this.addManyToQueue(videos, top); this.addManyToQueue(videos, top);
-7
View File
@@ -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); 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"; export { parseLastFmUrl, isLastFmUrl } from "./urlUtils.mjs";
+2 -8
View File
@@ -558,19 +558,13 @@ export class MessageHandler {
const { getVoiceManager } = await import("@fluxerjs/voice"); const { getVoiceManager } = await import("@fluxerjs/voice");
const channel = await this.client.channels.fetch(channelId).catch(() => null); const channel = await this.client.channels.fetch(channelId).catch(() => null);
if (!channel) throw new Error("Voice channel not found."); 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); const isGuildChannel = channel.isGuild?.() ?? ("guildId" in channel);
if (!isGuildChannel) throw new Error("Cannot join a non-guild voice channel."); if (!isGuildChannel) throw new Error("Cannot join a non-guild voice channel.");
const vm = getVoiceManager(this.client); const vm = getVoiceManager(this.client);
if (!vm) throw new Error("VoiceManager not available."); if (!vm) throw new Error("VoiceManager not available.");
const voiceConn = await vm.join(channel); 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 = () => { const deafen = () => {
try { try {
vm.updateVoiceState(channel.id, { self_deaf: true, self_mute: false }); vm.updateVoiceState(channel.id, { self_deaf: true, self_mute: false });
-1
View File
@@ -346,7 +346,6 @@ export class QueuePaginator {
try { try {
await rawMsg.removeAllReactions(); await rawMsg.removeAllReactions();
} catch (e) { } catch (e) {
// Message deleted — nothing left to clean up.
if (String(e?.message ?? e).includes("Message wasn't found") || e?.code === 10008) return; if (String(e?.message ?? e).includes("Message wasn't found") || e?.code === 10008) return;
for (const emoji of [prev, next]) { for (const emoji of [prev, next]) {
try { try {
-2
View File
@@ -65,14 +65,12 @@ export function get247ChannelMode(set, channelId) {
* Original GatewayHandler.mjs and index.mjs still import this. * Original GatewayHandler.mjs and index.mjs still import this.
*/ */
export function remove247ChannelMode(set, channelId, currentChannels) { 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. * No-op: per-channel modes removed. Kept for backward compatibility.
*/ */
export function set247ChannelMode(set, channelId, mode) { export function set247ChannelMode(set, channelId, mode) {
// No-op: modes no longer exist.
} }
/** /**
-2
View File
@@ -51,7 +51,6 @@ export function shardIdForGuild(client, guildId) {
if (Number.isInteger(id) && id >= 0) return id; if (Number.isInteger(id) && id >= 0) return id;
} }
} catch { } catch {
// fall through to the single-process default
} }
return 0; return 0;
} }
@@ -74,7 +73,6 @@ export function getLocalShards(client) {
return [...map.entries()].filter(([id]) => Number.isInteger(id)); return [...map.entries()].filter(([id]) => Number.isInteger(id));
} }
} catch { } catch {
// Fluxer 3.0: client.ws throws before login — treat as "no shards yet".
} }
return []; return [];
} }
-15
View File
@@ -117,15 +117,11 @@ class GatewayHandler {
const client = remix.client; const client = remix.client;
try { 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); const wsObjs = ShardingUtils.localShardSockets(client);
if (!remix._rawGatewayWsObjs) remix._rawGatewayWsObjs = new Set(); if (!remix._rawGatewayWsObjs) remix._rawGatewayWsObjs = new Set();
const attached = remix._rawGatewayWsObjs; const attached = remix._rawGatewayWsObjs;
// Detach listeners from sockets that went away (reconnects).
for (const old of attached) { for (const old of attached) {
if (wsObjs.includes(old)) continue; if (wsObjs.includes(old)) continue;
try { try {
@@ -142,8 +138,6 @@ class GatewayHandler {
let attachedNew = false; let attachedNew = false;
// Create the shared raw-socket handlers once (stateless parsers
// shared by every local shard socket).
if (!remix._rawGatewayHandler) { if (!remix._rawGatewayHandler) {
remix._rawGatewayHandler = (data) => { remix._rawGatewayHandler = (data) => {
try { try {
@@ -249,7 +243,6 @@ class GatewayHandler {
attachedNew = true; attachedNew = true;
} }
// Legacy singular field kept in sync (first socket) for compatibility.
remix._rawGatewayWsObj = wsObjs[0] ?? null; remix._rawGatewayWsObj = wsObjs[0] ?? null;
this.wsListenerAttached = attached.size > 0; this.wsListenerAttached = attached.size > 0;
if (attachedNew) { 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 { try {
if (client.ws?.send) { if (client.ws?.send) {
for (const id of ShardingUtils.localShardIds(client)) { 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); applyMixins(GatewayHandler, VoiceStateRouting, GuildSync, RejoinManager);
export { GatewayHandler }; export { GatewayHandler };
-4
View File
@@ -91,10 +91,6 @@ const RejoinManager = {
this._rejoinAttempts.delete(cleanChannelId); this._rejoinAttempts.delete(cleanChannelId);
return; 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( logger.voice247(
`[Rejoin] Existing player for ${cleanChannelId} has a dead connection — evicting before rejoin.` `[Rejoin] Existing player for ${cleanChannelId} has a dead connection — evicting before rejoin.`
); );
-15
View File
@@ -271,7 +271,6 @@ const VoiceStateRouting = {
const guildId = vsuGuildId; const guildId = vsuGuildId;
if (newChannelId && guildId && oldChannelId && oldChannelId !== newChannelId) { if (newChannelId && guildId && oldChannelId && oldChannelId !== newChannelId) {
// During boot recovery, ignore move events — the recovery loop handles rejoining.
if (this._bootRecoveryActive) { if (this._bootRecoveryActive) {
logger.voice247( logger.voice247(
`[247] Ignoring bot move ${cleanId(oldChannelId)} → ${cleanId(newChannelId)} during boot recovery.` `[247] Ignoring bot move ${cleanId(oldChannelId)} → ${cleanId(newChannelId)} during boot recovery.`
@@ -282,7 +281,6 @@ const VoiceStateRouting = {
const cleanNew = cleanId(newChannelId); const cleanNew = cleanId(newChannelId);
const cleanOld = cleanId(oldChannelId); const cleanOld = cleanId(oldChannelId);
// Check if old channel is a saved 24/7 channel
const oldIs247 = (() => { const oldIs247 = (() => {
try { try {
const set = remix.settingsMgr.getServer(guildId); const set = remix.settingsMgr.getServer(guildId);
@@ -290,7 +288,6 @@ const VoiceStateRouting = {
} catch (_) { return false; } } catch (_) { return false; }
})(); })();
// Check if new channel is a saved 24/7 channel or has a pending spawn
const newChannelSaved = (() => { const newChannelSaved = (() => {
try { try {
const set = remix.settingsMgr.getServer(guildId); const set = remix.settingsMgr.getServer(guildId);
@@ -302,9 +299,6 @@ const VoiceStateRouting = {
const existingPlayer = remix.players.playerMap.get(cleanOld); const existingPlayer = remix.players.playerMap.get(cleanOld);
if (oldIs247 && existingPlayer) { 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( logger.voice247(
`[247] Bot moved away from 24/7 channel ${cleanOld} → ${cleanNew}. ` + `[247] Bot moved away from 24/7 channel ${cleanOld} → ${cleanNew}. ` +
`Destroying stale player, scheduling rejoin for ${cleanOld}.` `Destroying stale player, scheduling rejoin for ${cleanOld}.`
@@ -324,13 +318,11 @@ const VoiceStateRouting = {
}, rejoinDelay); }, rejoinDelay);
} }
} else if (newChannelSaved || newChannelPendingSpawn) { } else if (newChannelSaved || newChannelPendingSpawn) {
// New channel is already 24/7 or being spawned — keep both, don't rekey.
logger.voice247( logger.voice247(
`[247] Keeping both channels ${cleanOld} and ${cleanNew} ` + `[247] Keeping both channels ${cleanOld} and ${cleanNew} ` +
`(saved=${newChannelSaved} pending=${newChannelPendingSpawn})` `(saved=${newChannelSaved} pending=${newChannelPendingSpawn})`
); );
} else if (existingPlayer && cleanNew !== cleanOld) { } else if (existingPlayer && cleanNew !== cleanOld) {
// Neither channel is 24/7 — safe to rekey the player.
const targetChannel = client.channels.get(cleanNew) const targetChannel = client.channels.get(cleanNew)
?? client.channels.get?.(cleanNew) ?? client.channels.get?.(cleanNew)
?? null; ?? 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) { } catch (e) {
logger.warn("[247] Bot move handler failed:", e.message); logger.warn("[247] Bot move handler failed:", e.message);
} }
@@ -375,11 +365,6 @@ const VoiceStateRouting = {
return; 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 graceSet = remix.settingsMgr.getServer(guildId);
const graceMode = graceSet ? get247ChannelMode(graceSet, cleanOld) : "off"; const graceMode = graceSet ? get247ChannelMode(graceSet, cleanOld) : "off";
if (graceMode === "on" && typeof remix.schedule247Rejoin === "function") { if (graceMode === "on" && typeof remix.schedule247Rejoin === "function") {