little changes

This commit is contained in:
NoLogicAlan committed 2026-06-16 22:34:11 +03:00
1 parent 862f326996
commit b7252fccaf
41 files changed
+261 -228

No files matched your search

+2 -1
View File
@@ -6,6 +6,7 @@
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { logger } from "../src/constants/Logger.mjs";
export const command = new CommandBuilder()
.setName("autoplay")
@@ -50,7 +51,7 @@ export async function run(msg, data) {
const pick = similar[Math.floor(Math.random() * Math.min(3, similar.length))];
query = `${pick.name} ${pick.artist}`.trim();
}
} catch(e) { }
} catch(e) { logger.warn("[Autoplay] Error:", e?.message); }
}
if (!query) {
+14 -13
View File
@@ -6,7 +6,8 @@
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { cleanId } from "../src/Utils.mjs";
import { cleanId } from "../src/MessageHandler.mjs";
import { logger } from "../src/constants/Logger.mjs";
import { getVoiceManager } from "@fluxerjs/voice";
import { ERROR_COLOR, WARN_COLOR, SUCCESS_COLOR, DANGER_COLOR } from "../src/constants/UI.mjs";
import { EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
@@ -78,7 +79,7 @@ function getBotGatewayVoiceState(client, guildId) {
if (channelId) return { userId: botId, channelId: cleanId(channelId) };
}
}
} catch(e) { }
} catch(e) { logger.warn("[Debug] Error:", e?.message); }
try {
const cleanGuild = cleanId(guildId);
const guild = client.guilds.get(cleanGuild) ?? client.guilds.get(guildId);
@@ -100,7 +101,7 @@ function getBotGatewayVoiceState(client, guildId) {
if (chId) return { userId: botId, channelId: cleanId(chId) };
}
}
} catch(e) { }
} catch(e) { logger.warn("[Debug] Error:", e?.message); }
}
/**
@@ -170,16 +171,16 @@ async function forceRejoinPlayer(ctx, player) {
const revoiceConn = ctx.revoice?.connections?.get(cleanChannelId);
if (revoiceConn) {
try { await ctx.revoice._destroyStaleConnection(cleanChannelId, revoiceConn); } catch(e) { }
try { await ctx.revoice._destroyStaleConnection(cleanChannelId, revoiceConn); } catch(e) { logger.warn("[Debug] Error:", e?.message); }
} else if (player.connection) {
try { player.connection.removeAllListeners(); } catch(e) { }
try { ctx.revoice?._leaveGateway?.(cleanChannelId, cleanGuildId); } catch(e) { }
try { ctx.revoice?.deleteConnection?.(cleanChannelId); } catch(e) { }
try { await player.connection.disconnect(); } catch(e) { }
try { player.connection.removeAllListeners(); } catch(e) { logger.warn("[Debug] Error:", e?.message); }
try { ctx.revoice?._leaveGateway?.(cleanChannelId, cleanGuildId); } catch(e) { logger.warn("[Debug] Error:", e?.message); }
try { ctx.revoice?.deleteConnection?.(cleanChannelId); } catch(e) { logger.warn("[Debug] Error:", e?.message); }
try { await player.connection.disconnect(); } catch(e) { logger.warn("[Debug] Error:", e?.message); }
}
try { await player.leave(); } catch(e) { }
try { player.destroy(); } catch(e) { }
try { await player.leave(); } catch(e) { logger.warn("[Debug] Error:", e?.message); }
try { player.destroy(); } catch(e) { logger.warn("[Debug] Error:", e?.message); }
await new Promise(r => setTimeout(r, REJOIN_DELAY_MS));
@@ -195,7 +196,7 @@ async function forceRejoinPlayer(ctx, player) {
newPlayer.queue.current = null;
await newPlayer.playNext();
if (wasPaused) newPlayer.pause();
} catch(e) { }
} catch(e) { logger.warn("[Debug] Error:", e?.message); }
}
if (wasAutoplay) newPlayer._autoplay = true;
@@ -579,7 +580,7 @@ export async function run(msg, data) {
: `Player Detail${pages[pageIdx].includes(",") ? "s" : ""}`;
const footerText = expired
? this.t(msg, "responses._common.controlsExpired")
: `${this.t(msg, "responses.eval.pageLabel", { page: pageIdx + 1, total: totalPages })} • ${this.t(msg, "responses.eval.navigateHint")}`;
: `${this.t(msg, "responses.debug.pageLabel", { page: pageIdx + 1, total: totalPages })} • ${this.t(msg, "responses.eval.navigateHint")}`;
const embedColor = (pageIdx === 0 && ghostConnections.length > 0) ? DANGER_COLOR : getGlobalColor();
const titleSuffix = (pageIdx === 0 && ghostConnections.length > 0) ? ` — ${ghostConnections.length} Ghost(s) Detected!` : "";
@@ -606,7 +607,7 @@ export async function run(msg, data) {
await replyMsg.message.removeAllReactions();
} catch {
for (const emoji of navEmojis) {
try { await replyMsg.message.removeReaction(emoji); } catch(e) { }
try { await replyMsg.message.removeReaction(emoji); } catch(e) { logger.warn("[Debug] Error:", e?.message); }
}
}
};
+2 -1
View File
@@ -6,6 +6,7 @@
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { logger } from "../src/constants/Logger.mjs";
import { inspect } from "node:util";
import { ERROR_COLOR, EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
@@ -245,7 +246,7 @@ export async function run(msg, data) {
for (const emoji of navEmojis) {
try {
await replyMsg.message.removeReaction(emoji);
} catch(e) { }
} catch(e) { logger.warn("[Eval] Error:", e?.message); }
}
}
};
+4 -3
View File
@@ -8,6 +8,7 @@ import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { Utils } from "../src/Utils.mjs";
import { PREV_EMOJI, NEXT_EMOJI, CANCEL_EMOJI } from "../src/constants/UI.mjs";
import { logger } from "../src/constants/Logger.mjs";
const NAV_EMOJIS = [PREV_EMOJI, NEXT_EMOJI, CANCEL_EMOJI];
@@ -286,14 +287,14 @@ export async function run(msg) {
try {
await menuMsg.message.react(emoji);
await Utils.sleep(50);
} catch(e) { }
} catch(e) { logger.warn("[Filter] Error:", e?.message); }
}
};
const removePageFilterEmojis = async (p) => {
const pageEmojis = getPageItems(p).map(f => f.emoji);
for (const emoji of pageEmojis) {
try { await menuMsg.message.removeReaction(emoji); } catch(e) { }
try { await menuMsg.message.removeReaction(emoji); } catch(e) { logger.warn("[Filter] Error:", e?.message); }
}
};
@@ -307,7 +308,7 @@ export async function run(msg) {
await menuMsg.message.removeAllReactions();
} catch (_) {
for (const emoji of [...FILTERS.map(f => f.emoji), ...NAV_EMOJIS]) {
try { await menuMsg.message.removeReaction(emoji); } catch(e) { }
try { await menuMsg.message.removeReaction(emoji); } catch(e) { logger.warn("[Filter] Error:", e?.message); }
}
}
};
+17 -19
View File
@@ -7,6 +7,7 @@ import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { Utils } from "../src/Utils.mjs";
import { logger } from "../src/constants/Logger.mjs";
import { PROVIDER_CHOICES } from "../src/constants/providers.mjs";
import { ERROR_COLOR, EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
@@ -118,7 +119,7 @@ async function getGuildLinkedUsers(guild) {
if (userId && !m.user?.bot) memberIds.push(String(userId));
}
}
} catch(e) { }
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
return memberIds;
}
@@ -199,7 +200,7 @@ export async function playLastFmCategory(ctx, msg, userId, category, options = {
`${categoryEmoji} Fetching your ${categoryLabel} tracks from Last.fm${resolveLabel}...`
)]
});
} catch { statusMsg = null; }
} catch (e) { logger.warn("[LastfmCmd] Error:", e?.message); statusMsg = null; }
let result;
try {
@@ -382,8 +383,7 @@ export async function run(msg, data) {
]
});
sent = true;
} catch {
}
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
const replyEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
@@ -705,7 +705,7 @@ export async function run(msg, data) {
await replyMsg.message.removeAllReactions();
} catch {
for (const emoji of navEmojis) {
try { await replyMsg.message.removeReaction(emoji); } catch(e) { }
try { await replyMsg.message.removeReaction(emoji); } catch(e) { logger.warn("[LastFm] Error:", e?.message); }
}
}
};
@@ -738,9 +738,7 @@ export async function run(msg, data) {
try {
lb = await lastfm.getLeaderboard(currentPage, 10);
} catch {
}
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
await replyMsg.edit(buildPage(currentPage)).catch(() => {});
});
@@ -898,7 +896,7 @@ export async function run(msg, data) {
this.t(msg, "responses.lastfm.whoknowsChecking", { artist: artistName })
)]
});
} catch { statusMsg = null; }
} catch (e) { logger.warn("[LastfmCmd] Error:", e?.message); statusMsg = null; }
const guild = msg.message?.guild ?? msg.message?.member?.guild;
const memberIds = await getGuildLinkedUsers(guild);
@@ -1144,7 +1142,7 @@ export async function run(msg, data) {
artistName = searchResult.artist;
trackName = searchResult.name;
}
} catch(e) { }
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
}
}
@@ -1227,7 +1225,7 @@ export async function run(msg, data) {
let similarTracks = [];
try {
similarTracks = await lastfm.getSimilarTracks(artistName, trackName, 5);
} catch(e) { }
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
if (similarTracks.length) {
const simStr = similarTracks.map(t => {
@@ -1485,7 +1483,7 @@ export async function run(msg, data) {
coverUrl = albumInfo.image;
albumTitle = `${albumInfo.name} by ${albumInfo.artist}`;
}
} catch(e) { }
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
}
if (!coverUrl) {
@@ -1498,7 +1496,7 @@ export async function run(msg, data) {
albumTitle = trackInfo.album.title;
}
}
} catch(e) { }
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
}
if (!coverUrl) {
@@ -1561,7 +1559,7 @@ export async function run(msg, data) {
statusMsg = await msg.reply({
embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.lastfm.affinityChecking"))]
});
} catch { statusMsg = null; }
} catch (e) { logger.warn("[LastfmCmd] Error:", e?.message); statusMsg = null; }
let affinityResults;
try {
@@ -1612,7 +1610,7 @@ export async function run(msg, data) {
statusMsg = await msg.reply({
embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.lastfm.crownsChecking"))]
});
} catch { statusMsg = null; }
} catch (e) { logger.warn("[LastfmCmd] Error:", e?.message); statusMsg = null; }
let crowns;
try {
@@ -1692,7 +1690,7 @@ export async function run(msg, data) {
artistName = searchResult.artist;
trackName = searchResult.name;
}
} catch(e) { }
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
}
}
@@ -1707,7 +1705,7 @@ export async function run(msg, data) {
statusMsg = await msg.reply({
embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.lastfm.whoknowsTrackChecking", { track: trackName, artist: artistName }))]
});
} catch { statusMsg = null; }
} catch (e) { logger.warn("[LastfmCmd] Error:", e?.message); statusMsg = null; }
const guild = msg.message?.guild ?? msg.message?.member?.guild;
const memberIds = await getGuildLinkedUsers(guild);
@@ -1788,7 +1786,7 @@ export async function run(msg, data) {
statusMsg = await msg.reply({
embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.lastfm.whoknowsAlbumChecking", { album: albumName, artistClause: artistName ? ` by **${artistName}**` : "" }))]
});
} catch { statusMsg = null; }
} catch (e) { logger.warn("[LastfmCmd] Error:", e?.message); statusMsg = null; }
const guild = msg.message?.guild ?? msg.message?.member?.guild;
const memberIds = await getGuildLinkedUsers(guild);
@@ -1969,7 +1967,7 @@ export async function run(msg, data) {
artistName = searchResult.artist;
trackName = searchResult.name;
}
} catch(e) { }
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
}
}
+1 -1
View File
@@ -32,7 +32,7 @@ function resolvePlayerGuildId(player, mapKey, client) {
/**
* Execute the leave command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
+1 -1
View File
@@ -24,7 +24,7 @@ export const command = new CommandBuilder()
/**
* Execute the list command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
+1 -1
View File
@@ -20,7 +20,7 @@ export const command = new CommandBuilder()
/**
* Execute the loop command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
+1 -2
View File
@@ -64,7 +64,7 @@ export async function run(message) {
] });
}
try { await loadingMsg.message.delete(); } catch(e) { }
try { await loadingMsg.message.delete(); } catch(e) { logger.warn("[Lyrics] Error:", e?.message); }
const syncIndicator = result.synced ? this.t(message, "responses.lyrics.syncedBadge") : "";
const displayTitle = Utils.cleanTitle(current.title);
@@ -193,7 +193,6 @@ export async function run(message) {
if (current.thumbnail) closedEmbed.setThumbnail(current.thumbnail);
msg.edit({ embeds: [closedEmbed] }).catch(() => {});
}, SESSION_MS);
} catch (err) {
clearInterval(loadingInterval);
logger.error("[Lyrics Command] Error:", err);
+3 -3
View File
@@ -24,7 +24,7 @@ export const command = new CommandBuilder()
/**
* Execute the move command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
@@ -32,8 +32,8 @@ export async function run(message, data) {
if (!p) return;
const from = data.get("from")?.value;
const to = data.get("to")?.value;
if (from == null || from < 1) return message.replyEmbed("Source position must be 1 or greater.").catch(() => {});
if (to == null || to < 1) return message.replyEmbed("Target position must be 1 or greater.").catch(() => {});
if (from === null || from === undefined || from < 1) return message.replyEmbed("Source position must be 1 or greater.").catch(() => {});
if (to === null || to === undefined || to < 1) return message.replyEmbed("Target position must be 1 or greater.").catch(() => {});
const res = p.move(from, to);
message.replyEmbed(res).catch(() => {});
}
+13 -9
View File
@@ -6,6 +6,7 @@
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { logger } from "../src/constants/Logger.mjs";
import { PROVIDER_CHOICES, parseInlineProvider } from "../src/constants/providers.mjs";
import { playLastFmCategory } from "./lastfm.mjs";
import { ERROR_COLOR } from "../src/constants/UI.mjs";
@@ -44,8 +45,9 @@ function parseLastFmUrl(url) {
}
return { artist, track, album, url };
} catch {
return null;
} catch (e) {
logger.warn("[Play] Error:", e?.message);
return null;
}
}
@@ -59,8 +61,9 @@ function isLastFmUrl(str) {
try {
const u = new URL(str);
return /^(?:www\.)?last\.fm$/i.test(u.hostname) && /^\/music\//.test(u.pathname);
} catch {
return false;
} catch (e) {
logger.warn("[Play] Error:", e?.message);
return false;
}
}
@@ -179,7 +182,7 @@ export const command = new CommandBuilder()
/**
* Execute the play command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
@@ -207,7 +210,7 @@ export async function run(message, data) {
.setColor(getGlobalColor())
.setDescription(this.t(message, "responses.play.searching"));
let statusMsg = null;
try { statusMsg = await message.reply({ embeds: [searchEmbed] }); } catch(e) { }
try { statusMsg = await message.reply({ embeds: [searchEmbed] }); } catch(e) { logger.warn("[Play] Error:", e?.message); }
const playQuery = `${parsed.track} ${parsed.artist}`.trim();
const messages = p.play(playQuery, false, provider === "lastfm" || provider === "lf" ? "yt" : provider, lastfmTrackMeta);
@@ -227,7 +230,7 @@ export async function run(message, data) {
.setColor(getGlobalColor())
.setDescription(this.t(message, "responses.play.searching"));
let statusMsg = null;
try { statusMsg = await message.reply({ embeds: [searchEmbed] }); } catch(e) { }
try { statusMsg = await message.reply({ embeds: [searchEmbed] }); } catch(e) { logger.warn("[Play] Error:", e?.message); }
const playQuery = parsed.artist;
const messages = p.play(playQuery, false, provider === "lastfm" || provider === "lf" ? "yt" : provider);
@@ -298,11 +301,11 @@ export async function run(message, data) {
`🔍 Searching Last.fm for **${query}**...`
)]
});
} catch(e) { }
} catch(e) { logger.warn("[Play] Error:", e?.message); }
try {
searchResult = await lastfm.searchTrack(query);
} catch(e) { }
} catch(e) { logger.warn("[Play] Error:", e?.message); }
if (!searchResult) {
const noResult = { embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
@@ -361,6 +364,7 @@ export async function run(message, data) {
try {
statusMsg = await message.reply({ embeds: [searchEmbed] });
} catch (err) {
logger.warn("[Play] Error:", err?.message);
}
const playQuery = lastfmTrackMeta
+4 -3
View File
@@ -8,6 +8,7 @@ import { Utils } from "../src/Utils.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
import { logger } from "../src/constants/Logger.mjs";
export const command = new CommandBuilder()
.setName("player")
@@ -148,7 +149,7 @@ export async function run(msg) {
try {
await message.message.react(control.emoji);
await Utils.sleep(50);
} catch(e) { }
} catch(e) { logger.warn("[Player] Error:", e?.message); }
}
}
@@ -168,7 +169,7 @@ export async function run(msg) {
for (const emoji of controlEmojis) {
try {
await message.message.removeReaction(emoji);
} catch(e) { }
} catch(e) { logger.warn("[Player] Error:", e?.message); }
}
}
};
@@ -191,7 +192,7 @@ export async function run(msg) {
for (const emoji of ["⬅️", "➡️", "❌"]) {
try {
await lyricsMsg.message.removeReaction(emoji);
} catch(e) { }
} catch(e) { logger.warn("[Player] Error:", e?.message); }
}
}
};
+1 -1
View File
@@ -36,7 +36,7 @@ export const command = new CommandBuilder()
/**
* Execute the playnext command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
+3 -2
View File
@@ -6,6 +6,7 @@
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { logger } from "../src/constants/Logger.mjs";
import { NUMBER_EMOJIS, CANCEL_EMOJI, PREV_EMOJI, NEXT_EMOJI } from "../src/constants/UI.mjs";
@@ -26,7 +27,7 @@ export const command = function() {
/**
* Execute the radio command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
@@ -69,7 +70,7 @@ export async function run(msg, data) {
await rawMsg.removeAllReactions();
} catch (_) {
for (const emoji of baseEmojis) {
try { await rawMsg.removeReaction(emoji); } catch(e) { }
try { await rawMsg.removeReaction(emoji); } catch(e) { logger.warn("[Radio] Error:", e?.message); }
}
}
};
+1 -1
View File
@@ -125,7 +125,7 @@ async function showResults(msg, results, label) {
/**
* Execute the reload command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
+2 -2
View File
@@ -17,14 +17,14 @@ export const command = new CommandBuilder()
/**
* Execute the remove command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
const p = await this.getPlayer(message, false, false, false);
if (!p) return;
const index = data.get("index")?.value;
if (index == null || index < 1) return message.replyEmbed("Queue position must be 1 or greater.").catch(() => {});
if (index === null || index === undefined || index < 1) return message.replyEmbed("Queue position must be 1 or greater.").catch(() => {});
const res = p.remove(index - 1);
message.replyEmbed(res).catch(() => {});
}
+3 -2
View File
@@ -8,6 +8,7 @@ import { Message, getGlobalColor } from "../src/MessageHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { PROVIDER_CHOICES, PROVIDER_NAMES, parseInlineProvider } from "../src/constants/providers.mjs";
import { NUMBER_EMOJIS, CANCEL_EMOJI } from "../src/constants/UI.mjs";
import { logger } from "../src/constants/Logger.mjs";
export const command = new CommandBuilder()
.setName("search")
@@ -38,7 +39,7 @@ export const command = new CommandBuilder()
/**
* Execute the search command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
@@ -115,7 +116,7 @@ export async function run(msg, data) {
const clearReactions = async () => {
try {
await rawMsg.removeAllReactions();
} catch(e) { }
} catch(e) { logger.warn("[Search] Error:", e?.message); }
};
const wrapped = new Message(rawMsg, this.messages);
+1 -1
View File
@@ -22,7 +22,7 @@ export const command = new CommandBuilder()
/**
* Execute the seek command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
+2 -1
View File
@@ -7,6 +7,7 @@ import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
import { logger } from "../src/constants/Logger.mjs";
export const command = new CommandBuilder()
.setName("servers")
@@ -96,7 +97,7 @@ export async function run(msg) {
for (const emoji of navEmojis) {
try {
await replyMsg.message.removeReaction(emoji);
} catch(e) { }
} catch(e) { logger.warn("[Servers] Error:", e?.message); }
}
}
};
+8 -5
View File
@@ -6,6 +6,7 @@
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor, cleanId, getMessageGuildId } from "../src/MessageHandler.mjs";
import { logger } from "../src/constants/Logger.mjs";
import runnables from "../settings/runnables.mjs";
function embed(desc, opts = {}) {
@@ -15,9 +16,11 @@ function embed(desc, opts = {}) {
return { embeds: [b] };
}
/** Build a rich embed with fields for the 24/7 status panel.
* Instead, we build the base embed with EmbedBuilder, call .toJSON()
* to get the raw object, then attach a `fields` array directly.
/**
* Build a rich embed with fields for the 24/7 status panel.
* Instead of using the standard addField API, we build the base embed with
* EmbedBuilder, call .toJSON() to get the raw object, then attach a `fields`
* array directly.
*/
function richEmbed(fields, opts = {}) {
const b = new EmbedBuilder().setColor(getGlobalColor());
@@ -183,7 +186,7 @@ function resolveChannelName(client, channelId) {
try {
const ch = client?.channels?.get?.(channelId);
if (ch?.name) return ch.name;
} catch(e) { }
} catch(e) { logger.warn("[Settings] Error:", e?.message); }
return null;
}
@@ -689,7 +692,7 @@ export const command = function() {
/**
* Execute the settings command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
+3 -2
View File
@@ -52,8 +52,9 @@ async function fetchGuildMemberCount(guild) {
}, "0");
}
return total;
} catch {
return guild.memberCount ?? guild.members?.size ?? 0;
} catch (e) {
logger.warn("[Stats] Error:", e?.message);
return guild.memberCount ?? guild.members?.size ?? 0;
}
}
+2 -2
View File
@@ -15,8 +15,8 @@ export const command = new CommandBuilder()
/**
* run function.
* @param {{*}} msg
* @returns {*}
* @param {object} msg
* @returns {void}
*/
export function run(msg) {
const embed = new EmbedBuilder()
+3 -2
View File
@@ -6,6 +6,7 @@
import { CommandBuilder } from "../src/CommandHandler.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/MessageHandler.mjs";
import { logger } from "../src/constants/Logger.mjs";
export const command = new CommandBuilder()
.setName("test")
@@ -15,7 +16,7 @@ export const command = new CommandBuilder()
/**
* Execute the test command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
@@ -67,7 +68,7 @@ export async function run(msg, data) {
try {
const fetched = await this.client.channels.fetch(channelId);
if (fetched?.name) return fetched.name;
} catch(e) { }
} catch(e) { logger.warn("[Test] Error:", e?.message); }
return `Unknown (${channelId})`;
};
+1 -1
View File
@@ -72,7 +72,7 @@ function extractAlias(parts) {
/**
* Execute the trackopt command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
+2 -2
View File
@@ -23,7 +23,7 @@ export const command = new CommandBuilder()
/**
* Execute the volume command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
@@ -35,7 +35,7 @@ export async function run(message, data) {
const embed = new EmbedBuilder().setColor(getGlobalColor());
if (!volOption || raw == null || isNaN(Number(raw))) {
if (!volOption || raw === null || raw === undefined || isNaN(Number(raw))) {
const current = Math.round((p.preferredVolume ?? 1) * 100);
embed.setDescription(this.t(message, "responses.volume.current", { volume: current }));
} else {
+1 -1
View File
@@ -24,7 +24,7 @@ export const command = new CommandBuilder()
/**
* Execute the volumedefault command.
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(message, data) {
+6 -4
View File
@@ -9,6 +9,7 @@ import { getGlobalColor } from "../src/MessageHandler.mjs";
import { Utils } from "../src/Utils.mjs";
import { FLUXERLIST, buildVoteLink } from "../src/constants/API.mjs";
import { ERROR_COLOR, EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
import { logger } from "../src/constants/Logger.mjs";
export const command = new CommandBuilder()
@@ -102,7 +103,7 @@ function buildVotersEmbed(voters, total, page, limit, type, resourceId, expired
/**
* Execute the vote command.
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
* @param {Map<string, {value: *}>>} data - Slash-command options map
* @param {Map<string, {value: *}>} data - Slash-command options map
* @returns {Promise<void>}
*/
export async function run(msg, data) {
@@ -207,7 +208,7 @@ export async function run(msg, data) {
await replyMsg.message.removeAllReactions();
} catch {
for (const emoji of navEmojis) {
try { await replyMsg.message.removeReaction(emoji); } catch(e) { }
try { await replyMsg.message.removeReaction(emoji); } catch(e) { logger.warn("[Vote] Error:", e?.message); }
}
}
};
@@ -240,10 +241,11 @@ export async function run(msg, data) {
try {
voterData = await fluxerlist.getVoters(resolvedType, id, { page: currentPage, limit: 20 });
} catch {
} catch (e) {
logger.warn("[Vote] Re-fetch failed for page " + currentPage + ":", e?.message);
}
if (!voterData) return;
await replyMsg.edit(buildPage(currentPage, voterData)).catch(() => {});
});
+7 -8
View File
@@ -188,7 +188,7 @@ export class Remix {
commands.owners = config.owners ?? [];
this.moonlink = null;
let moonlinkInitialised = false;
const moonlinkInitialised = false;
this.voiceCache = new VoiceStateCache({ maxUsers: 50_000, maxBots: 10_000 });
@@ -376,7 +376,7 @@ export class Remix {
}
}
}
} catch(e) { }
} catch(e) { logger.warn("[AloneCheck] Voice state check error:", e?.message); }
}
if (!hasHuman) {
@@ -386,7 +386,7 @@ export class Remix {
hasHuman = true;
logger.aloneCheck(`[AloneCheck] Found ${room.remoteParticipants.size} LiveKit remote participant(s) in ${channelId}`);
}
} catch(e) { }
} catch(e) { logger.warn("[AloneCheck] LiveKit check error:", e?.message); }
}
logger.aloneCheck(`[AloneCheck] channel=${channelId} guild=${guildId} hasHuman=${hasHuman} paused=${player._paused}`);
@@ -409,7 +409,6 @@ export class Remix {
}
}, ALONE_CHECK_INTERVAL);
const self = this;
this.players.checkVoiceChannels = async function (message) {
const userId = message?.author?.id ?? message?.message?.author?.id;
const guildId =
@@ -570,7 +569,7 @@ export class Remix {
}))
.then(results => {
const succeeded = results.filter(r => r.status === "fulfilled").length;
const failed = results.filter(r => r.status === "rejected").length;
const failed = results.length - succeeded;
logger.commands(`Modules loaded (${succeeded} succeeded, ${failed} failed).`);
});
@@ -791,7 +790,7 @@ export class Remix {
}
});
} catch(e) {
logger.warn("[Player] Song announcement error:", e?.message);
}
});
@@ -821,7 +820,7 @@ export class Remix {
this.players._pendingJoins.delete(cleanChannelId);
}
this.players.playerMap.delete(cleanChannelId);
try { player.destroy(); } catch(e) { }
try { player.destroy(); } catch(e) { logger.warn("[_spawnPlayer] Cleanup destroy error:", e?.message); }
logger.warn(`[_spawnPlayer] Failed to spawn player for channel ${cleanChannelId}:`, err.message);
throw err;
}
@@ -939,7 +938,7 @@ export class Remix {
try {
const member = await guild.members.fetch(user.id).catch(() => null);
if (member) isMember = true;
} catch (_) { }
} catch (_) { logger.warn("[AloneCheck] Member fetch error for", user.id); }
}
if (!isMember) continue;
+3 -4
View File
@@ -176,8 +176,6 @@ export class Option {
const results = this.channelRegex.exec(i) ?? this.idRegex.exec(i);
const guildId = msg?.channel?.guildId ?? msg?.guildId;
if (guildId === "eval") return (results) ? results.groups["id"] : i;
const voiceTypes = [2, 13];
const byName = msg?.guild?.channels?.find(c => c.name === i && voiceTypes.includes(c.type));
const cObj = results
@@ -573,7 +571,7 @@ export class CommandHandler extends EventEmitter {
try {
const names = botPermResult.missing.map(k => REQUIRED_BOT_PERMISSIONS.get(k)?.name ?? k);
msg.message?.reply?.("I'm missing critical permissions: **" + names.join("**, **") + "**. Ask an admin to fix this.", { ping: false });
} catch (__) { }
} catch (__) { logger.warn("[CommandHandler] Fallback perm reply failed"); }
}
return;
}
@@ -639,7 +637,8 @@ export class CommandHandler extends EventEmitter {
const data = collectArguments(argIndex, value, [value]);
if (!data) { const twGuildId = msg.channel?.channel?.guildId ?? msg.message?.guildId; return this.replyHandler(this._textWrapErrorMsg(twGuildId, args.slice(argIndex).join(" "), args[argIndex].charAt(0)), msg); }
argIndex += data.index - argIndex;
value = data.args.join(" ").slice(1, data.args.join(" ").length - 1);
const _joined = data.args.join(" ");
value = _joined.slice(1, _joined.length - 1);
}
argIndex++;
i--;
+1 -1
View File
@@ -102,7 +102,7 @@ export class GatewayHandler {
if (guild.members && !guild.members.me) {
await guild.members.fetchMe();
}
} catch (_) { }
} catch (_) { logger.warn("[GatewayHandler] fetchMe failed"); }
const channels = guild.channels;
if (!channels) return;
+67 -74
View File
@@ -233,7 +233,8 @@ export class LastFmManager {
try {
await pool.execute("ALTER TABLE \`lastfm_users\` ADD COLUMN \`scrobble_count\` BIGINT NOT NULL DEFAULT 0 AFTER \`scrobble\`");
} catch {
} catch (e) {
logger.warn("[LastFm] Migration warning:", e?.message);
}
await pool.execute(`
@@ -296,7 +297,8 @@ export class LastFmManager {
`UPDATE lastfm_stats SET linked_users = linked_users + 1 WHERE id = 1${f.where} AND NOT EXISTS (SELECT 1 FROM (SELECT 1 FROM lastfm_users WHERE user_id = ?${f.where} AND linked_at < NOW()) AS tmp)`,
[...f.params, String(userId), ...f.params]
);
} catch {
} catch (e) {
logger.warn("[LastFm] Migration warning:", e?.message);
}
return data;
@@ -520,8 +522,9 @@ export class LastFmManager {
try {
const data = await apiCall(params, this.apiSecret);
return data.track;
} catch {
return null;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return null;
}
}
@@ -729,9 +732,7 @@ export class LastFmManager {
url: t.url ?? "",
match: parseFloat(t.match ?? 0),
})).filter(t => t.match > 0.1);
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -776,8 +777,9 @@ export class LastFmManager {
})),
userplaycount: a.stats?.userplaycount ? Number(a.stats.userplaycount) : null,
};
} catch {
return null;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return null;
}
}
@@ -822,8 +824,9 @@ export class LastFmManager {
})),
userplaycount: a.userplaycount ? Number(a.userplaycount) : null,
};
} catch {
return null;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return null;
}
}
@@ -854,9 +857,7 @@ export class LastFmManager {
playcount: Number(t.playcount ?? 0),
image: t.image?.[2]?.["#text"] ?? t.image?.[1]?.["#text"] ?? "",
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -886,9 +887,7 @@ export class LastFmManager {
playcount: Number(a.playcount ?? 0),
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -917,9 +916,7 @@ export class LastFmManager {
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
match: parseFloat(a.match ?? 0),
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -950,9 +947,7 @@ export class LastFmManager {
url: t.url ?? "",
count: Number(t.count ?? 0),
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -983,8 +978,9 @@ export class LastFmManager {
count: Number(t.taggings?.total ?? t.total ?? 0),
summary: t.wiki?.summary ?? "",
};
} catch {
return null;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return null;
}
}
@@ -1015,9 +1011,7 @@ export class LastFmManager {
playcount: Number(t.playcount ?? 0),
image: t.image?.[2]?.["#text"] ?? t.image?.[1]?.["#text"] ?? "",
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1046,9 +1040,7 @@ export class LastFmManager {
playcount: Number(a.playcount ?? 0),
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1082,8 +1074,9 @@ export class LastFmManager {
username: user.username,
playcount,
};
} catch {
return {
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return {
userId: uid,
username: user.username,
playcount: 0,
@@ -1151,8 +1144,9 @@ export class LastFmManager {
commonArtists,
matchPercentage,
};
} catch {
return null;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return null;
}
}
@@ -1181,9 +1175,7 @@ export class LastFmManager {
from: Number(c.from ?? 0),
to: Number(c.to ?? 0),
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1219,9 +1211,7 @@ export class LastFmManager {
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
listeners: Number(a.listeners ?? 0),
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1257,9 +1247,7 @@ export class LastFmManager {
url: a.url ?? "",
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1296,8 +1284,9 @@ export class LastFmManager {
}
return { artist, track, album, url };
} catch {
return null;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return null;
}
}
@@ -1311,8 +1300,9 @@ export class LastFmManager {
try {
const u = new URL(str);
return /^(?:www\.)?last\.fm$/i.test(u.hostname) && /^\/music\//.test(u.pathname);
} catch {
return false;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return false;
}
}
@@ -1604,9 +1594,7 @@ export class LastFmManager {
query: `${t.name} ${t.artist ?? ar.name}`,
image: t.image ?? ar.image ?? "",
}));
} catch {
return [];
}
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
})
);
for (const r of artistResults) {
@@ -1716,8 +1704,9 @@ export class LastFmManager {
[...f.params]
);
return Number(rows[0]?.linked_users ?? 0);
} catch {
return 0;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return 0;
}
}
@@ -1776,8 +1765,9 @@ export class LastFmManager {
[String(playcount), String(userId), ...f.params]
);
return playcount;
} catch {
return 0;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return 0;
}
}
@@ -1805,7 +1795,7 @@ export class LastFmManager {
realname: f.realname ?? "",
country: f.country ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1834,7 +1824,7 @@ export class LastFmManager {
playcount: Number(a.playcount ?? 0),
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1864,7 +1854,7 @@ export class LastFmManager {
playcount: Number(t.playcount ?? 0),
image: t.image?.[2]?.["#text"] ?? t.image?.[1]?.["#text"] ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1894,7 +1884,7 @@ export class LastFmManager {
playcount: Number(a.playcount ?? 0),
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1917,7 +1907,7 @@ export class LastFmManager {
url: t.url ?? "",
count: Number(t.count ?? 0),
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1942,7 +1932,7 @@ export class LastFmManager {
url: t.url ?? "",
count: Number(t.count ?? 0),
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1967,7 +1957,7 @@ export class LastFmManager {
url: t.url ?? "",
count: Number(t.count ?? 0),
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -1992,7 +1982,7 @@ export class LastFmManager {
playcount: Number(a.playcount ?? 0),
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -2016,7 +2006,7 @@ export class LastFmManager {
listeners: Number(a.listeners ?? 0),
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -2041,7 +2031,7 @@ export class LastFmManager {
listeners: Number(t.listeners ?? 0),
image: t.image?.[2]?.["#text"] ?? t.image?.[1]?.["#text"] ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -2065,7 +2055,7 @@ export class LastFmManager {
playcount: Number(t.playcount ?? 0),
image: t.image?.[2]?.["#text"] ?? t.image?.[1]?.["#text"] ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -2088,7 +2078,7 @@ export class LastFmManager {
playcount: Number(a.playcount ?? 0),
image: a.image?.[2]?.["#text"] ?? a.image?.[1]?.["#text"] ?? "",
}));
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
/**
@@ -2121,8 +2111,9 @@ export class LastFmManager {
username: user.username,
playcount,
};
} catch {
return {
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return {
userId: uid,
username: user.username,
playcount: 0,
@@ -2172,8 +2163,9 @@ export class LastFmManager {
username: user.username,
playcount,
};
} catch {
return {
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return {
userId: uid,
username: user.username,
playcount: 0,
@@ -2216,8 +2208,9 @@ export class LastFmManager {
try {
const artists = await this.getTopArtists(uid, "overall", 50);
return { uid, username: user.username, artists };
} catch {
return null;
} catch (e) {
logger.warn("[LastFm] Error:", e?.message);
return null;
}
})
);
@@ -2295,7 +2288,7 @@ export class LastFmManager {
crowns.sort((a, b) => b.userPlaycount - a.userPlaycount);
return crowns;
} catch { return []; }
} catch (e) { logger.warn("[LastFm] Error:", e?.message); return []; }
}
_assertEnabled() {
+4 -4
View File
@@ -245,7 +245,7 @@ export class MessageHandler {
async assertPermissions(permissions, message) {
const guild = message.guild ?? await message.client?.guilds?.resolve?.(message.guildId);
if (guild && !guild.members?.me) {
try { await guild.members.fetchMe(); } catch (_) { }
try { await guild.members.fetchMe(); } catch (_) { logger.warn("[MessageHandler] fetchMe failed"); }
}
const missing = this.checkPermissions(permissions, message.channel ?? message.channel?.channel);
if (missing.length === 0) return true;
@@ -270,7 +270,7 @@ export class MessageHandler {
try {
const names = missing.map(k => REQUIRED_BOT_PERMISSIONS.get(k)?.name ?? k);
await message.reply(this.t(message.guildId, "responses.messages.needPermsFallback", { perms: names.join("** **") }), { ping: false });
} catch (_) { }
} catch (_) { logger.warn("[MessageHandler] Fallback permission reply failed"); }
}
return false;
}
@@ -991,7 +991,7 @@ export class RichPaginator {
for (const emoji of allReactions) {
try {
await rawMsg.removeReaction(emoji);
} catch(e) { }
} catch(e) { logger.warn("[MessageHandler] Error:", e?.message); }
}
};
@@ -1090,7 +1090,7 @@ export class QueuePaginator {
for (const emoji of [prev, next]) {
try {
await rawMsg.removeReaction(emoji);
} catch(e) { }
} catch(e) { logger.warn("[MessageHandler] Error:", e?.message); }
}
}
};
+11 -13
View File
@@ -17,8 +17,7 @@
* that occurs when a Fluxer bot token is sent to an incompatible API.
*/
import Revoicejs from "revoice.js";
const { MediaPlayer } = Revoicejs;
import { MediaPlayer } from "revoice.js";
import { ConnectionState, LKRoomEvent } from "./constants/FluxerRevoice.mjs";
import { getVoiceManager } from "@fluxerjs/voice";
@@ -33,7 +32,6 @@ import { getGlobalColor } from "./MessageHandler.mjs";
import { logger } from "./constants/Logger.mjs";
import { get247ChannelMode } from "./constants/Helpers247.mjs";
import { PROVIDER_NAMES } from "./constants/providers.mjs";
import { cleanId } from "./Utils.mjs";
import { hasHumansInChannel } from "./constants/VoiceStateResolver.mjs";
@@ -587,7 +585,7 @@ export default class Player extends EventEmitter {
logger.mediaplayer("[Player] Existing MediaPlayer unhealthy, cleaning up...");
try {
if (this._mediaPlayer.fProc) {
try { this._mediaPlayer.fProc.removeAllListeners(); } catch(e) { }
try { this._mediaPlayer.fProc.removeAllListeners(); } catch(e) { logger.warn("[Player] Error removing listeners:", e?.message); }
}
await this._mediaPlayer.stop();
} catch(e) { logger.warn("[Player] MediaPlayer stop error:", e?.message); }
@@ -674,7 +672,7 @@ export default class Player extends EventEmitter {
if (this._mediaPlayer) {
try {
if (this._mediaPlayer.fProc) {
try { this._mediaPlayer.fProc.removeAllListeners(); } catch(e) { }
try { this._mediaPlayer.fProc.removeAllListeners(); } catch(e) { logger.warn("[Player] Error removing listeners:", e?.message); }
}
await this._mediaPlayer.stop();
@@ -720,7 +718,7 @@ export default class Player extends EventEmitter {
if (_redirects >= 5) return reject(new Error("Too many redirects"));
const redirectUrl = new URL(loc);
if (redirectUrl.host !== urlObj.host) {
delete options.headers?.Authorization;
if (options.headers) delete options.headers.Authorization;
}
return fetchUrl(loc, _redirects + 1);
}
@@ -801,7 +799,7 @@ export default class Player extends EventEmitter {
try {
if (typeof audioStream.unpipe === "function") audioStream.unpipe();
if (typeof audioStream.destroy === "function") audioStream.destroy();
} catch (e) { }
} catch (e) { logger.warn("[Player] Error:", e?.message); }
}
this._currentPassthrough = null;
};
@@ -885,10 +883,9 @@ export default class Player extends EventEmitter {
this._mediaPlayer.once("finish", onFinish);
this._mediaPlayer.once("error", onError);
});
} catch (e) {
if (audioStream && !audioStream.destroyed) {
try { audioStream.destroy(); } catch (e2) { }
try { audioStream.destroy(); } catch (e2) { logger.warn("[Player] Error destroying stream:", e2?.message); }
}
this._currentPassthrough = null;
if (isIgnorableMediaStateError(e)) {
@@ -1266,7 +1263,7 @@ export default class Player extends EventEmitter {
}
this._stopMediaPlayer().catch(() => {}).then(() => {
if (connToDestroy) {
try { connToDestroy.removeAllListeners?.(); } catch(e) { }
try { connToDestroy.removeAllListeners?.(); } catch(e) { logger.warn("[Player] Error removing listeners:", e?.message); }
const disconnectPromise = connToDestroy.disconnect?.();
if (disconnectPromise instanceof Promise) {
disconnectPromise.catch((err) => {
@@ -1779,8 +1776,9 @@ export default class Player extends EventEmitter {
msg: `${vcLine}📻 **[${current.title}](${current.author?.url || current.url})**\n${current.description || ""}\n\n🎵 Now playing: ${data?.title || "Unknown"}\n\n🔉 ${vol} │ ${loopqueue} Queue │ ${songloop} Song │ ${autoplay} Autoplay`,
image: current.thumbnail
};
} catch {
return {
} catch (e) {
logger.warn("[Player] Error:", e?.message);
return {
msg: `${vcLine}📻 **[${current.title}](${current.author?.url || current.url})**\n\n🔉 ${vol} │ ${loopqueue} Queue │ ${songloop} Song │ ${autoplay} Autoplay`,
image: current.thumbnail
};
@@ -2036,7 +2034,7 @@ export default class Player extends EventEmitter {
if (this._mediaPlayer) {
try {
if (this._mediaPlayer.fProc) {
try { this._mediaPlayer.fProc.removeAllListeners(); } catch(e) { }
try { this._mediaPlayer.fProc.removeAllListeners(); } catch(e) { logger.warn("[Player] Error removing listeners:", e?.message); }
}
await this._mediaPlayer.stop();
} catch(e) { logger.warn("[Player] MediaPlayer stop on next track:", e?.message); }
+3 -2
View File
@@ -107,8 +107,9 @@ export class TrackOptionsManager {
try {
const u = new URL(track.url);
return `${u.hostname}${u.pathname}`.replace(/\/+$/, "").toLowerCase().trim();
} catch {
return track.url.toLowerCase().trim();
} catch (e) {
logger.warn("[TrackOptions] Error:", e?.message);
return track.url.toLowerCase().trim();
}
}
const artist = track.artist || track.author?.name || "";
+3 -2
View File
@@ -216,8 +216,9 @@ export class Utils {
try {
new URL(str);
return true;
} catch {
return false;
} catch (e) {
logger.warn("[Utils] Error:", e?.message);
return false;
}
}
+3 -3
View File
@@ -62,7 +62,7 @@ function isLiveKitLogMessage(...args) {
try {
const parsed = JSON.parse(args[0]);
if (parsed.name === "lk-rtc") return true;
} catch (_e) { }
} catch (_e) { logger.warn("[FluxerRevoice] Error parsing livekit args"); }
}
if (LIVEKIT_LOG_PREFIXES.some(p => args[0].includes(p))) return true;
}
@@ -370,7 +370,7 @@ export class FluxerRevoice extends EventEmitter {
existing._destroyed = true;
existing._connected = false;
try { existing.removeAllListeners(); } catch (e) { }
try { existing.removeAllListeners(); } catch (e) { logger.warn("[FluxerRevoice] Error removing listeners:", e?.message); }
}
/**
@@ -474,7 +474,7 @@ export class FluxerRevoice extends EventEmitter {
warn: (...args) => { if (!isLiveKitLogMessage(...args)) logger.warn("[LiveKit]", ...args); },
error: (...args) => logger.error("[LiveKit]", ...args),
});
} catch (_e) { }
} catch (_e) { logger.warn("[FluxerRevoice] Error creating LiveKit logger adapter"); }
}
if (!room) {
+7 -8
View File
@@ -6,6 +6,7 @@
import { readFileSync, readdirSync, existsSync } from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { logger } from "./Logger.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const LOCALES_DIR = path.resolve(__dirname, "../../storage/locales/bot");
@@ -53,7 +54,7 @@ export class Locale {
this._resolved.clear();
if (!existsSync(LOCALES_DIR)) {
console.warn(`[Locale] Locales directory not found: ${LOCALES_DIR}`);
logger.warn("[Locale] Locales directory not found:", LOCALES_DIR);
return;
}
@@ -61,7 +62,7 @@ export class Locale {
try {
files = readdirSync(LOCALES_DIR).filter(f => f.endsWith(".json"));
} catch (e) {
console.warn(`[Locale] Failed to read locales directory: ${e.message}`);
logger.warn("[Locale] Failed to read locales directory:", e.message);
return;
}
@@ -72,13 +73,11 @@ export class Locale {
const data = JSON.parse(readFileSync(filePath, "utf8"));
this.locales.set(code, data);
} catch (e) {
console.warn(`[Locale] Failed to load ${file}: ${e.message}`);
logger.warn("[Locale] Failed to load " + file + ":", e.message);
}
}
console.log(
`[Locale] Loaded ${this.locales.size} locale(s): ${[...this.locales.keys()].join(", ")}`
);
logger.info("[Locale] Loaded " + this.locales.size + " locale(s): " + [...this.locales.keys()].join(", "));
}
/**
@@ -113,7 +112,7 @@ export class Locale {
code = setting;
}
}
} catch(e) { }
} catch(e) { logger.warn("[Locale] Error:", e?.message); }
const data = this.locales.get(code) ?? this.locales.get(this.defaultLocale) ?? {};
this._resolved.set(guildId, data);
@@ -161,7 +160,7 @@ export class Locale {
const prefix = serverSettings.get("prefix");
if (prefix) return prefix;
}
} catch(e) { }
} catch(e) { logger.warn("[Locale] Error:", e?.message); }
return this._defaultPrefix || "!";
}
+19 -1
View File
@@ -1,3 +1,13 @@
/**
* @file StreamMerger.mjs — StreamMerger — Transform stream that mixes multiple audio inputs through FFmpeg amix filter
* @module src.constants.audio.StreamMerger
*/
/**
* StreamMerger extends Transform to mix multiple audio streams into one
* using FFmpeg’s amix filter. Supports dynamic stream addition with
* a tree-based node structure for managing merge slots.
*/
import { logger } from "../Logger.mjs";
import ffmpeg from "ffmpeg-static";
import { Transform } from "node:stream";
@@ -26,7 +36,14 @@ class StreamMerger extends Transform {
this.ffmpeg.stdout.on("data", (chunk) => { this.push(chunk); });
}
spawnFfmpeg() {
const args = "-i pipe:3 -re -i pipe:4 -vn -fflags nobuffer -filter_complex amix=inputs=2:duration=longest pipe:1".split(" ");
const args = [
"-i", "pipe:3",
"-re", "-i", "pipe:4",
"-vn",
"-fflags", "nobuffer",
"-filter_complex", "amix=inputs=2:duration=longest",
"pipe:1",
];
return spawn(this.ffmpegPath, args, {
windowsHide: true,
stdio: ["pipe", "pipe", "pipe", "pipe", "pipe"]
@@ -60,6 +77,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). */
p.stdio[4].write(Buffer.alloc(1024, 0));
p.stdout.pipe(open.process.stdio[open.pipes[0]]);
const pipeNumber = open.pipes[0];
+22 -13
View File
@@ -1,3 +1,12 @@
/**
* @file Tuna.mjs — Tuna — Voicemod Tuna API client for sound effect search and download
* @module src.constants.audio.Tuna
*/
/**
* Tuna API client for searching and downloading sound effects
* from the Voicemod Tuna service (tuna-api.voicemod.net).
*/
import pkg from "follow-redirects";
const { https } = pkg;
@@ -7,11 +16,9 @@ class Tuna {
this.apiKey = auth.key;
}
get(path, params = {}) {
return new Promise((resolve, rej) => {
let query = "";
for (let key in params) {
query += ((query.length === 0) ? "?" : "&") + key + "=" + encodeURIComponent(params[key]);
}
return new Promise((resolve, reject) => {
const qs = new URLSearchParams(params).toString();
const query = qs ? "?" + qs : "";
const options = {
method: "GET",
hostname: "tuna-api.voicemod.net",
@@ -19,21 +26,21 @@ class Tuna {
headers: { "x-api-key": this.apiKey },
maxRedirects: 20
};
const req = https.request(options, function(res) {
const req = https.request(options, (res) => {
const chunks = [];
res.on("data", (chunk) => { chunks.push(chunk); });
res.on("end", () => {
try {
resolve(JSON.parse(Buffer.concat(chunks).toString()));
} catch (e) {
rej(new Error(`Tuna API JSON parse error: ${e.message}`));
reject(new Error(`Tuna API JSON parse error: ${e.message}`));
}
});
});
req.on("error", (error) => { rej(error); });
req.on("error", (error) => { reject(error); });
req.setTimeout(15_000, () => {
req.destroy();
rej(new Error("Tuna API request timeout"));
reject(new Error("Tuna API request timeout"));
});
req.end();
});
@@ -41,9 +48,10 @@ class Tuna {
search(query, page = 1, size = 10) {
return this.get("/v1/sounds/search", { size, page, search: query }).then(results => {
results.items = results.items.map(s => {
s.download = function() {
const oggPath = s.oggPath;
s.download = () => {
return new Promise((resolve, reject) => {
const req = https.get(this.oggPath, { maxRedirects: 20 }, (r) => { resolve(r); });
const req = https.get(oggPath, { maxRedirects: 20 }, (r) => { resolve(r); });
req.on("error", (err) => { reject(err); });
req.setTimeout(15_000, () => { req.destroy(); reject(new Error("Tuna download timeout")); });
});
@@ -55,9 +63,10 @@ class Tuna {
}
getSound(id) {
return this.get("/v1/sounds/" + id).then(sound => {
sound.download = function() {
const oggPath = sound.oggPath;
sound.download = () => {
return new Promise((resolve, reject) => {
const req = https.get(this.oggPath, { maxRedirects: 20 }, (result) => { resolve(result); });
const req = https.get(oggPath, { maxRedirects: 20 }, (result) => { resolve(result); });
req.on("error", (err) => { reject(err); });
req.setTimeout(15_000, () => { req.destroy(); reject(new Error("Tuna download timeout")); });
});
+8 -8
View File
@@ -42,7 +42,7 @@ export class Dashboard {
case "fetchPlayers":
return [...this.remix.players.playerMap.values()]
.filter(p => !p._destroyed)
.map(p => { try { return Dashboard.convertPlayer(p); } catch(_) { return null; } })
.map(p => { try { return Dashboard.convertPlayer(p); } catch(e) { logger.warn("[Dashboard] convertPlayer error:", e?.message); return null; } })
.filter(Boolean);
case "user": {
@@ -209,7 +209,7 @@ export class Dashboard {
data: String(user.id)
}));
}
} catch (_) { }
} catch (_) { logger.warn("[Dashboard] Error:", _.message); }
}
return { message: "Already Connected" };
}
@@ -349,7 +349,7 @@ export class Dashboard {
data: String(user.id)
}));
}
} catch (_) { }
} catch (_) { logger.warn("[Dashboard] Error:", _.message); }
return { message: "Left channel" };
}
try {
@@ -465,7 +465,7 @@ export class Dashboard {
if (!vid) return null;
const durationMs =
typeof vid.duration === "number" ? vid.duration :
typeof vid.duration === "object" && vid.duration?.seconds != null ? vid.duration.seconds * 1000 :
typeof vid.duration === "object" && vid.duration?.seconds !== null ? vid.duration.seconds * 1000 :
0;
return {
title: vid.title,
@@ -542,7 +542,7 @@ export class Dashboard {
if (guild.icon) {
iconUrl = `https://fluxerusercontent.com/icons/${guild.id}/${guild.icon}.webp`;
} else if (typeof guild.iconURL === "function") {
try { iconUrl = guild.iconURL() ?? null; } catch (_) { iconUrl = null; }
try { iconUrl = guild.iconURL() ?? null; } catch (e) { logger.warn("[Dashboard] iconURL error:", e?.message); iconUrl = null; }
}
return {
@@ -566,7 +566,7 @@ export class Dashboard {
if (guild.icon) {
iconUrl = `https://fluxerusercontent.com/icons/${guild.id}/${guild.icon}.webp`;
} else if (typeof guild.iconURL === "function") {
try { iconUrl = guild.iconURL() ?? null; } catch (_) { iconUrl = null; }
try { iconUrl = guild.iconURL() ?? null; } catch (e) { logger.warn("[Dashboard] iconURL error:", e?.message); iconUrl = null; }
}
return {
name: guild.name,
@@ -625,7 +625,7 @@ export class Dashboard {
for (const [mapUserId, info] of vc) {
if (seen.has(mapUserId)) continue;
const infoCh = cleanId(info.channelId);
const infoG = cleanId(info.guildId);
const infoG = cleanId(info.guildId);
if (infoCh === cleanChannelId && infoG === cleanGuildId) {
const botId = player.client?.user?.id;
if (botId && String(mapUserId) === String(botId)) continue;
@@ -800,7 +800,7 @@ export class Dashboard {
let res;
try {
res = await this.db.execute("SELECT * FROM login_codes WHERE user=? AND (verified IS NULL OR verified != true)", [user]);
res = await this.db.execute("SELECT * FROM login_codes WHERE user=? AND (verified IS NULL OR verified !== true)", [user]);
} catch (e) {
const id = Utils.uid();
logger.dashboard("[Dashboard] MySQL error, id:", id, e);
+1 -1
View File
@@ -24,7 +24,7 @@ export default function probe(file) {
const cleanup = () => {
settled = true;
clearTimeout(timeoutHandle);
try { proc.kill(); } catch(e) { }
try { proc.kill(); } catch(e) { /* process already exited */ }
};
const timeoutHandle = setTimeout(() => {