refactor: centralize shared utilities, fix voice intent, and improve error visibility

- extract `cleanId()` to `Utils.mjs` and remove 97+ inline `String(x).replace(/\D/g, "")` duplicates

- add `VoiceStateResolver.mjs` with `iterateVoiceStates`, `hasHumansInChannel`, `getChannelsWithHumans` — eliminates 12+ duplicated voice-state-iteration blocks across `Player`, `PlayerManager`, `GatewayHandler`, `Dashboard`

- add `UI.mjs` for shared color, emoji, and timeout constants

- move `parseInlineProvider` to `providers.mjs`, `getMessageGuildId` to `MessageHandler.mjs`

- fix `VoiceStateCache.removeGuild` and `TrackOptionsManager` cache deletion mutating Maps during iteration

- fix `checkVoiceChannels` now async returning `{channelId, alreadyInVoice, hasHumans}` — all callers updated

- fix `FluxerRevoice` global `console.log` monkey-patch replaced with scoped `withSuppressedLiveKitLogs(fn)`

- fix `Player._get247Mode()` settings resolution chain

- fix `runnables.mjs` validators were no-ops

- promote `Player` magic numbers to named static constants

- replace all silent `catch (_) {}` with `logger.warn()` throughout

- remove unused deps: `express`, `genius-lyrics`, `ws`

- add `@file` JSDoc headers to all modules
This commit is contained in:
NoLogicAlan committed 2026-06-15 16:56:10 +03:00
1 parent 0d3035b093
commit 092268281a
67 files changed
+2520 -2179

No files matched your search

+19 -11
View File
@@ -1,3 +1,8 @@
/**
* @file reload.mjs — Hot-reload commands without restarting the bot (owner-only)
* @module commands.reload
*/
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
@@ -16,9 +21,6 @@ export const command = new CommandBuilder()
)
.setRequirement(r => r.setOwnerOnly(true));
function embed(desc) {
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
}
const __dirname = path.dirname(new URL(import.meta.url).pathname);
const ROOT = path.resolve(__dirname, "..");
@@ -88,17 +90,17 @@ async function showPaged(msg, title, lines, pageSize = 14) {
const arrows = ["⬅️", "➡️"];
const curr = { n: 0 };
const mkEmbed = (n) => ({
const buildPageEmbed = (n) => ({
embeds: [
new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(title)
.setDescription(pages[n].join("\n") + (pages.length > 1 ? `\n\nPage **${n + 1}** / **${pages.length}**` : ""))
]
});
const m = await msg.reply(mkEmbed(0));
const m = await msg.reply(buildPageEmbed(0));
if (!m || pages.length <= 1) return;
m.message.react(arrows[0]).catch(() => {});
@@ -107,7 +109,7 @@ async function showPaged(msg, title, lines, pageSize = 14) {
const unsub = m.onReaction(arrows, (e) => {
if (e.emoji_id === arrows[0]) curr.n = Math.max(0, curr.n - 1);
else curr.n = Math.min(pages.length - 1, curr.n + 1);
m.edit(mkEmbed(curr.n)).catch(() => {});
m.edit(buildPageEmbed(curr.n)).catch(() => {});
});
setTimeout(() => { unsub?.(); }, 5 * 60_000);
@@ -120,6 +122,12 @@ async function showResults(msg, results, label) {
await showPaged(msg, `🔄 Reload — ${label}`, [header, "", ...results.map(r => r.msg)]);
}
/**
* Execute the reload command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
const target = (data.get("target")?.value ?? "").trim().toLowerCase();
@@ -178,7 +186,7 @@ export async function run(msg, data) {
if (this.handler.commands.some(c => c.name === target)) {
const res = await reloadCommand(this, msg, target);
return msg.reply(embed(res.msg));
return msg.reply(res.msg);
}
const allMods = [...allModuleFiles("src"), ...allModuleFiles("audio")];
@@ -189,10 +197,10 @@ export async function run(msg, data) {
if (mod) {
const res = await reloadModule(this, msg, mod.file, mod.label);
return msg.reply(embed(res.msg));
return msg.reply(res.msg);
}
return msg.reply(embed(
return msg.reply(
this.t(msg, "responses.reload.unknownTarget", { target })
));
);
}