From 50ac37de13e929e3f7ad8fc8228d24fa6bb50ecd Mon Sep 17 00:00:00 2001 From: NoLogicAlan Date: Tue, 11 Aug 2026 03:22:58 +0300 Subject: [PATCH] fix: correct client cache config, remove dead intents, clean up comments & JSDoc --- index.mjs | 3 +-- src/CommandHandler.mjs | 21 +++++++++++++++++++++ src/MessageHandler.mjs | 4 ++++ src/Player.mjs | 12 ++++++++++++ src/Settings.mjs | 9 +++++++++ src/TrackOptionsManager.mjs | 3 +++ src/constants/FluxerRevoice.mjs | 13 +++++++++++-- src/constants/audio/StreamMerger.mjs | 5 ++++- src/constants/audio/Tuna.mjs | 4 ++++ 9 files changed, 69 insertions(+), 5 deletions(-) diff --git a/index.mjs b/index.mjs index 71e7a0d..3795b67 100644 --- a/index.mjs +++ b/index.mjs @@ -101,9 +101,8 @@ export class Remix { const client = new Client({ suppressIntentWarning: true, waitForGuilds: true, - cache: { guilds: 0, channels: 0, users: 0, members: 0 }, + cache: { guilds: false, channels: false, users: false, members: false }, ...config["fluxer.js"], - intents: 1 << 7, presence: (() => { if (presenceContents.length === 0) return undefined; const entry = presenceContents[0]; diff --git a/src/CommandHandler.mjs b/src/CommandHandler.mjs index c39c0c9..efb3a3c 100644 --- a/src/CommandHandler.mjs +++ b/src/CommandHandler.mjs @@ -113,6 +113,9 @@ export class Option { /** @type {Function} */ dynamicDefault; + /** + * @param {string} [type="string"] Option value type — "string", "number", "boolean", "channel", "user", or "text" + */ constructor(type = "string") { this.name = null; this.description = null; @@ -247,6 +250,9 @@ export class Option { * Flag class. */ export class Flag extends Option { + /** + * @param {string} [type="string"] Flag value type — anything Option supports except "text" + */ constructor(type = "string") { if (type === "text") throw new Error("Flags can't be of type 'text'!"); super(type); @@ -261,6 +267,10 @@ export class PrefixManager { settings; /** @type {string|null} Prefix from config.json — used as fallback when DB has no value */ configPrefix; + /** + * @param {SettingsManager} settings Settings manager used to look up per-guild prefixes + * @param {string|null} [configPrefix=null] Fallback prefix from config.json when no DB value exists + */ constructor(settings, configPrefix = null) { this.settings = settings; this.configPrefix = configPrefix; } getPrefix(guildId) { const serverPrefix = this.settings.getServer(guildId).get("prefix"); @@ -294,6 +304,9 @@ export class HelpHandler { customHelpHandler = null; + /** + * @param {CommandBuilder[]} commands Loaded command list to generate help pages from + */ constructor(commands) { this.commands = commands; } static capitalise(string) { @@ -436,6 +449,10 @@ export class CommandHandler extends EventEmitter { _cmdCooldowns = new Map(); _cmdCooldownMs = 1500; + /** + * @param {MessageHandler} handler MessageHandler instance to listen for incoming messages on + * @param {string} [prefix="%"] Default command prefix used when no per-guild prefix is set + */ constructor(handler, prefix = "%") { super(); this.messages = handler; @@ -812,6 +829,10 @@ export class CommandLoader { runnables = new Map(); context; + /** + * @param {Map} commands Map that loaded commands will be registered into + * @param {Object} context Shared context object (client, settings, locale, etc.) passed to command factories + */ constructor(commands, context) { this.commands = commands; this.context = context; diff --git a/src/MessageHandler.mjs b/src/MessageHandler.mjs index 0baf55f..e1a9367 100644 --- a/src/MessageHandler.mjs +++ b/src/MessageHandler.mjs @@ -702,6 +702,10 @@ export class Message { /** @type {MessageHandler} */ handler; + /** + * @param {import("@fluxerjs/core").Message} message Underlying raw Fluxer.js message instance + * @param {MessageHandler} handler Owning MessageHandler, used for replies, pagination, and reaction observers + */ constructor(message, handler) { this.message = message; this.handler = handler; diff --git a/src/Player.mjs b/src/Player.mjs index 38068f8..f80cbef 100644 --- a/src/Player.mjs +++ b/src/Player.mjs @@ -90,6 +90,11 @@ function isIgnorableMediaStateError(err) { } class PlayerWorkerPool { + /** + * @param {number} size Number of worker threads to spawn in the pool + * @param {string} workerPath Filesystem path to the worker script (see src/worker.mjs) + * @param {Object} [nlConfig={}] NodeLink connection config passed to each worker on init + */ constructor(size, workerPath, nlConfig = {}) { this._size = size; this._workerPath = workerPath; @@ -368,6 +373,13 @@ export default class Player extends EventEmitter { requestTimeout: 60_000, }; + /** + * @param {string} token Bot token (kept for revoice.js API compatibility; unused by FluxerRevoice) + * @param {Object} [opts={}] Player configuration, merged over DEFAULT_OPTS + * @param {import("@fluxerjs/core").Client} [opts.client] Fluxer client instance + * @param {string} [opts.channelId] Voice channel ID to bind this player to + * @param {string} [opts.guildId] Guild ID the voice channel belongs to + */ constructor(token, opts = {}) { super(); diff --git a/src/Settings.mjs b/src/Settings.mjs index d56fe3e..b17064a 100644 --- a/src/Settings.mjs +++ b/src/Settings.mjs @@ -33,6 +33,10 @@ export class ServerSettings { manager; data = {}; + /** + * @param {string} id Guild ID these settings belong to + * @param {SettingsManager} mgr Owning settings manager, used for defaults and persistence + */ constructor(id, mgr) { this.id = id; this.manager = mgr; @@ -71,6 +75,11 @@ export class RemoteSettingsManager extends SettingsManager { _loadPromise = null; _debounceTimers = new Map(); + /** + * @param {Object} config MySQL connection config passed to mysql2's createPool + * @param {string} defaultsPath Filesystem path to the JSON file with default guild settings + * @param {string|null} [botId=null] Bot user ID for multi-bot row isolation, or null for single-bot mode + */ constructor(config, defaultsPath, botId = null) { super(); this.botId = botId; diff --git a/src/TrackOptionsManager.mjs b/src/TrackOptionsManager.mjs index c4a404f..7ce2d0b 100644 --- a/src/TrackOptionsManager.mjs +++ b/src/TrackOptionsManager.mjs @@ -21,6 +21,9 @@ export class TrackOptionsManager { _cache = new Map(); _cacheMaxSize = 2000; + /** + * @param {Object} mysqlConfig MySQL connection config passed to mysql2's createPool + */ constructor(mysqlConfig) { this.db = mysql.createPool({ connectionLimit: 10, ...mysqlConfig }); this.db.on("error", (err) => { diff --git a/src/constants/FluxerRevoice.mjs b/src/constants/FluxerRevoice.mjs index 8aea024..42edce5 100644 --- a/src/constants/FluxerRevoice.mjs +++ b/src/constants/FluxerRevoice.mjs @@ -175,6 +175,12 @@ export class FluxerVoiceConnection extends EventEmitter { this._users = Array.isArray(val) ? val : []; } + /** + * @param {string} channelId Voice channel ID this connection is bound to + * @param {FluxerRevoice} voice Parent FluxerRevoice instance that owns the join queue and users map + * @param {Object} [opts={}] Connection options + * @param {any} [opts.room] LiveKit Room instance, if already available at construction time + */ constructor(channelId, voice, opts = {}) { super(); this.channelId = channelId; @@ -290,6 +296,9 @@ export class FluxerRevoice extends EventEmitter { return FluxerRevoice._instance; } + /** + * @param {import("@fluxerjs/core").Client} client Fluxer client used to resolve channels/guilds and send gateway leave signals + */ constructor(client) { super(); if (FluxerRevoice._instance && FluxerRevoice._instance !== this) { @@ -642,7 +651,7 @@ export class FluxerRevoice extends EventEmitter { } }); - /** + /* * Handle the VoiceManager's serverLeave event, which fires when * the Fluxer/LiveKit server terminates the session server-side. * Without this handler the bot never learns the session is dead, @@ -661,7 +670,7 @@ export class FluxerRevoice extends EventEmitter { this.connections.delete(channelId); this._leaveGateway(channelId, channelGuildId); if (room) { - try { room.disconnect().catch(() => {}); } catch (_) { /** already gone */ } + try { room.disconnect().catch(() => {}); } catch (_) { /* already gone */ } } if (conn.listenerCount("disconnect") > 0) { conn.emit("disconnect"); diff --git a/src/constants/audio/StreamMerger.mjs b/src/constants/audio/StreamMerger.mjs index 1027b99..e2dd707 100644 --- a/src/constants/audio/StreamMerger.mjs +++ b/src/constants/audio/StreamMerger.mjs @@ -18,6 +18,9 @@ class StreamMerger extends Transform { ffmpeg = null; streamTree = []; + /** + * @param {import("node:stream").TransformOptions} streamOptions Options forwarded to the underlying Transform stream + */ constructor(streamOptions) { super(streamOptions); } @@ -77,7 +80,7 @@ class StreamMerger extends Transform { open.children.push(node); s.pipe(p.stdio[3]); p.stderr.on("data", (c) => { logger.mediaplayer("[ffmpeg]", c.toString().trim()); }); - /** Write initial silence to prime the ffmpeg stdin pipe (required for amix to detect the input). */ + /* Write initial silence to prime the ffmpeg stdin pipe (required for amix to detect the input). */ p.stdio[4].write(Buffer.alloc(1024, 0)); p.stdout.pipe(open.process.stdio[open.pipes[0]]); const pipeNumber = open.pipes[0]; diff --git a/src/constants/audio/Tuna.mjs b/src/constants/audio/Tuna.mjs index c695a82..ca50487 100644 --- a/src/constants/audio/Tuna.mjs +++ b/src/constants/audio/Tuna.mjs @@ -12,6 +12,10 @@ const { https } = pkg; class Tuna { apiKey = null; + /** + * @param {Object} auth Auth config + * @param {string} auth.key Voicemod Tuna API key + */ constructor(auth) { this.apiKey = auth.key; }