feat: audio filters, rate limiting, stability fixes & new announcement channel

feat(filter): add %filter command with Bass Boost, Nightcore, Vaporwave,
  8D, Karaoke, Tremolo and more; filter status now shown in %player UI

feat(player): add Filter button (🎛️) to player controls; display active
  filter name/emoji in queue status line

feat(commands): add per-user command cooldown (1.5s) in CommandHandler;
  owners are exempt so %reload/%eval are never blocked

feat(settings): debounce rapid set() calls into a single remoteSave()
  80ms after the last write; prevents N parallel DB queries per command

feat(storage): add announcementChannelId field to defaults.json

fix(play): wrap statusMsg send in try/catch; fall back to fresh reply
  if the initial status message fails to send

fix(stats): normalise guild.members.fetch() result (Collection, array,
  or plain object) to avoid infinite pagination loop; use memberCount
  as primary member count

fix(search): normalise reaction event user ID across Fluxer event shapes
  (user_id / userId / user.id) so author filter works reliably

fix(forceleave): await this.players.leave() — was missing await, could
  silently swallow errors

fix(MessageHandler): guard register() against double-call on hot-reload;
  second call now returns early to prevent duplicate listeners

fix(MoonlinkManager): add getLiveSessionId() helper that walks active
  nodes to find a valid session before falling back to cached value

fix(reload): use pathToFileURL() for cache-busting import URL so Windows
  drive letters and spaces in paths are handled correctly

fix(eval): broaden sensitive-key list (mysql, nodelink, _nl, credential,
  apikey, webhook); increase scan depth to 6; handle circular refs in
  hasSensitive(); normalise keys to lowercase for matching

fix(worker): compile sanitize regexes once at module load instead of
  on every sanitizeError() call

fix(Player): cache compiled sanitize regexes keyed by host:port:password
  to avoid rebuilding identical RegExp objects on every error path

fix(index): wrap config.json read in try/catch with clear FATAL messages
  for missing file or malformed JSON; validate required keys at startup

config: add rest.timeout/retries and nodelink requestTimeout to
  config_example.json with explanatory comments
This commit is contained in:
NoLogicAlan committed 2026-04-23 17:19:49 +03:00
1 parent c339e32e9c
commit 57f018c815
17 files changed
+468 -232

No files matched your search

+24
View File
@@ -376,6 +376,12 @@ export class CommandHandler extends EventEmitter {
invalidFlagError = "Invalid flag `$invalidFlag`. It doesn't match any options on this command.\n`$previousCmd $invalidFlag`";
textWrapError = "Malformed string `$value`: Missing a closing quote character (`$quote`) after the desired string.";
// Per-user rate limiting: userId → timestamp of last processed command
// Prevents command spam that could saturate worker threads and fill the searches Map.
// Owners are exempt so they can always use debug/reload commands.
_cmdCooldowns = new Map();
_cmdCooldownMs = 1500; // 1.5 seconds between commands per user
constructor(handler, prefix = "!") {
super();
this.messages = handler;
@@ -421,6 +427,24 @@ export class CommandHandler extends EventEmitter {
}
return;
}
// Per-user rate limit — skip spam commands silently.
// Owners are always exempt so %reload and %eval are never blocked.
const userId = msg.message?.author?.id ?? msg.author?.id;
if (userId && !this.owners.includes(userId)) {
const now = Date.now();
const last = this._cmdCooldowns.get(userId) ?? 0;
if (now - last < this._cmdCooldownMs) return;
this._cmdCooldowns.set(userId, now);
// Evict stale entries periodically to keep the Map from growing unbounded.
// 500 entries × 8 bytes ≈ negligible, but good hygiene on busy bots.
if (this._cmdCooldowns.size > 500) {
const cutoff = now - this._cmdCooldownMs * 2;
for (const [uid, ts] of this._cmdCooldowns) {
if (ts < cutoff) this._cmdCooldowns.delete(uid);
}
}
}
const guildId = msg.channel?.channel?.guildId ?? msg.message?.guildId;
const prefix = this.getPrefix(guildId);
const ping = `<@${this.client.user?.id}>`;