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

+15 -5
View File
@@ -1,8 +1,14 @@
/**
* @file lyrics.mjs — Fetch and display lyrics for the current or specified song
* @module commands.lyrics
*/
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { logger } from "../src/constants/Logger.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { Utils } from "../src/Utils.mjs";
import { EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
export const command = new CommandBuilder()
.setName("lyrics")
@@ -11,9 +17,13 @@ export const command = new CommandBuilder()
.setCategory("music");
const LOADING_FRAMES = ["◐", "◓", "◑", "◒"];
const EMOJI_REMOVE_TIMEOUT = 60_000;
const SESSION_MS = 180_000;
/**
* Execute the lyrics command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @returns {Promise<void>}
*/
export async function run(message) {
const p = await this.getPlayer(message, false, false, false);
if (!p) return;
@@ -28,7 +38,7 @@ export async function run(message) {
const loadingMsg = await message.reply({ embeds: [
new EmbedBuilder().setColor(getGlobalColor())
.setDescription(`${LOADING_FRAMES[0]} ` + this.t(message, "responses.lyrics.searching", { title: Utils.truncate(current.title, 40) }))
] });
const loadingInterval = setInterval(() => {
@@ -36,7 +46,7 @@ export async function run(message) {
loadingMsg.edit({ embeds: [
new EmbedBuilder().setColor(getGlobalColor())
.setDescription(`${LOADING_FRAMES[frame]} ` + this.t(message, "responses.lyrics.searching", { title: Utils.truncate(current.title, 40) }))
] }).catch(() => {});
}, 800);
@@ -54,7 +64,7 @@ export async function run(message) {
] });
}
try { await loadingMsg.message.delete(); } catch {}
try { await loadingMsg.message.delete(); } catch(e) { }
const syncIndicator = result.synced ? this.t(message, "responses.lyrics.syncedBadge") : "";
const displayTitle = Utils.cleanTitle(current.title);
@@ -189,4 +199,4 @@ export async function run(message) {
logger.error("[Lyrics Command] Error:", err);
loadingMsg.edit({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(message, "responses.lyrics.error", { error: Utils.truncate(err.message, 100) }))] }).catch(() => {});
}
}
}