Files
fluxer/commands/debug.mjs
T
NoLogicAlan 253d11cd57 Remix — the complete rewrite
Upgrades the bot from fluxerjs 2.2 to 3.0 and restructures everything
into a layered architecture (~28K lines):

Dependencies:
- @fluxerjs/core, util, voice: ^2.2.0 -> ^3.0.0 (typed events,
  PartialMessage payloads, camelCase API)
- @fluxerjs/sharding ^3.0.0 added — built-in sharding mode
  (shard.mjs, one process per shard)
- @discordjs/opus dropped — opusscript + prism-media cover encoding

Architecture:
- commands: every command split into submodules (player, lastfm,
  settings, debug) with a shared CommandBuilder/Loader/Handler core
- ui: embeds, paginators, help command, permission checks
- voice: gateway event routing, rejoin/247 boot recovery, state resolver
- music: player split into Queue/Search/Playback/Display mixins,
  stream pipeline + WebM/Opus muxer (no FFmpeg needed)
- dashboard: Redis pub/sub, RPC handlers, serializers
- db: MySQL manager + per-guild settings
- services: LastFm manager split into focused mixins
- utils: sharding, 24/7 helpers, API client

Runtime fixes over v2:
- Redis v5 reconnect: capped numeric backoff (0.5s ramp to 15s),
  never exhausts, auto-recovers when the server comes back
- Redis main/subscriber clients connect in parallel; clean shutdown
- Logger storm guard: identical error/warn lines deduped in a 60s window
- self-deaf fix on voice join
- config example uses redis://127.0.0.1 (avoids IPv6 ENETUNREACH)

Housekeeping: dead code removed (Tuna.mjs + follow-redirects dep),
.gitignore added (config.json, .env, node_modules, runtime state).
2026-09-09 02:04:33 +03:00

65 lines
2.2 KiB
JavaScript

/**
* @module commands/debug
* @description Owner-only debug command for voice diagnostics, ghost connection
* detection, and forced rejoin. The implementations live in commands/debug/
* (gateway, rejoin, voiceDiagnostic); the builder and run() dispatch stay here.
*/
import { CommandBuilder } from "../src/commands/index.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { ERROR_COLOR } from "../src/utils/UI.mjs";
import { isGhostConnection } from "./debug/gateway.mjs";
import { runBatchRejoin } from "./debug/rejoin.mjs";
import { runVoiceDiagnostic } from "./debug/voiceDiagnostic.mjs";
/**
* @type {CommandBuilder}
* @description Command definition for the debug command (owner-only).
*/
export const command = new CommandBuilder()
.setName("debug")
.setDescription("A debug command for various purposes.")
.setRequirement(r => r.setOwnerOnly(true))
.setCategory("util")
.addChoiceOption(o =>
o.setName("target")
.setDescription("The target that should be examined.")
.addChoices("voice", "voice-rejoin", "247-rejoin")
.setRequired(true));
/**
* Run handler for the debug command.
* Routes to the appropriate debug subcommand based on the target option.
*
* @param {object} msg - The command message wrapper.
* @param {object} data - Parsed command data containing the target option.
* @returns {Promise<void>}
*/
export async function run(msg, data) {
const target = data.get("target").value;
switch (target) {
case "247-rejoin": {
return await runBatchRejoin.call(this, msg, "247-rejoin", "24/7 Rejoin", "24/7 channel(s)", p => !!p._home247Channel);
}
case "voice-rejoin": {
return await runBatchRejoin.call(this, msg, "voice-rejoin", "Voice Rejoin", "ghost connection(s)", isGhostConnection, true);
}
case "voice": {
return await runVoiceDiagnostic.call(this, msg);
}
default: {
const embed = new EmbedBuilder()
.setColor(ERROR_COLOR)
.setTitle("Debug — Unknown Target")
.setDescription(`Unknown debug target: \`${target}\`.\nValid options: \`voice\`, \`voice-rejoin\`, \`247-rejoin\`.`)
;
return msg.reply({ embeds: [embed] });
}
}
}