mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
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:
1 parent
0d3035b093
commit
092268281a
67 files changed
+2520
-2179
No files matched your search
+12
-2
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file autoplay command — Toggle autoplay to automatically play similar tracks when the queue ends
|
||||
* @module commands/autoplay
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -8,6 +13,12 @@ export const command = new CommandBuilder()
|
||||
.setCategory("music")
|
||||
.addAliases("ap");
|
||||
|
||||
/**
|
||||
* Execute the autoplay 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 p = await this.getPlayer(msg, true, true, false);
|
||||
if (!p) return;
|
||||
@@ -39,8 +50,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 (_) {
|
||||
}
|
||||
} catch(e) { }
|
||||
}
|
||||
|
||||
if (!query) {
|
||||
|
||||
+12
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file clear command — Remove all songs from the queue
|
||||
* @module commands/clear
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -8,6 +13,12 @@ export const command = new CommandBuilder()
|
||||
.addAliases("c")
|
||||
.setCategory("music");
|
||||
|
||||
/**
|
||||
* Execute the clear 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) {
|
||||
const p = await this.getPlayer(msg, false, false, false);
|
||||
if (!p) return;
|
||||
@@ -16,5 +27,5 @@ export async function run(msg) {
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(this.t(msg, "responses.clear.cleared"))
|
||||
;
|
||||
msg.reply({ embeds: [embed] });
|
||||
msg.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+75
-34
@@ -1,12 +1,24 @@
|
||||
/**
|
||||
* @file debug command — Owner-only debug utilities for voice connections, ghost detection, and forced rejoins
|
||||
* @module commands/debug
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { cleanId } from "../src/Utils.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";
|
||||
|
||||
const EMOJI_REMOVE_TIMEOUT = 60_000;
|
||||
const REJOIN_DELAY_MS = 2_000;
|
||||
const INTENTIONAL_LEAVE_TTL = 30_000;
|
||||
|
||||
/**
|
||||
* Return a human-readable label for a voice room's connection state.
|
||||
* @param {object} room - The voice room instance
|
||||
* @returns {string}
|
||||
*/
|
||||
function roomStateLabel(room) {
|
||||
if (!room) return "none";
|
||||
const cs = room.connectionState;
|
||||
@@ -20,6 +32,12 @@ function roomStateLabel(room) {
|
||||
return String(cs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect whether a player has a "ghost" connection — the player object exists
|
||||
* but the underlying voice room is disconnected, reconnecting, or absent.
|
||||
* @param {import("../src/Player.mjs").default} player
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isGhostConnection(player) {
|
||||
const conn = player.connection;
|
||||
if (!conn) return false;
|
||||
@@ -41,22 +59,28 @@ function isGhostConnection(player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the bot's voice state from the gateway cache for a given guild.
|
||||
* @param {object} client - The Discord client instance
|
||||
* @param {string} guildId - The guild ID to look up
|
||||
* @returns {{ userId: string, channelId: string } | null}
|
||||
*/
|
||||
function getBotGatewayVoiceState(client, guildId) {
|
||||
const botId = client.user?.id;
|
||||
if (!botId || !guildId) return null;
|
||||
try {
|
||||
const vm = getVoiceManager(client);
|
||||
if (vm?.voiceStates) {
|
||||
const cleanGuild = String(guildId).replace(/\D/g, "");
|
||||
const cleanGuild = cleanId(guildId);
|
||||
const guildVoiceMap = vm.voiceStates.get(cleanGuild) ?? vm.voiceStates.get(guildId);
|
||||
if (guildVoiceMap && typeof guildVoiceMap.get === "function") {
|
||||
const channelId = guildVoiceMap.get(botId);
|
||||
if (channelId) return { userId: botId, channelId: String(channelId).replace(/\D/g, "") };
|
||||
if (channelId) return { userId: botId, channelId: cleanId(channelId) };
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
try {
|
||||
const cleanGuild = String(guildId).replace(/\D/g, "");
|
||||
const cleanGuild = cleanId(guildId);
|
||||
const guild = client.guilds.get(cleanGuild) ?? client.guilds.get(guildId);
|
||||
const voiceStates = guild?.voice_states ?? guild?.voiceStates ?? null;
|
||||
if (!voiceStates) return null;
|
||||
@@ -73,13 +97,18 @@ function getBotGatewayVoiceState(client, guildId) {
|
||||
const uid = state?.user_id ?? state?.userId ?? state?.id;
|
||||
if (uid === botId) {
|
||||
const chId = state?.channel_id ?? state?.channelId ?? null;
|
||||
if (chId) return { userId: botId, channelId: String(chId).replace(/\D/g, "") };
|
||||
if (chId) return { userId: botId, channelId: cleanId(chId) };
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
return null;
|
||||
} catch(e) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the gateway voice state is stale compared to the player's expected channel.
|
||||
* @param {object} client - The Discord client instance
|
||||
* @param {import("../src/Player.mjs").default} player
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isStaleGatewayPresence(client, player) {
|
||||
const guildId = player._guildId ?? player._resolveGuildId?.();
|
||||
if (!guildId) return false;
|
||||
@@ -87,7 +116,7 @@ function isStaleGatewayPresence(client, player) {
|
||||
const gatewayState = getBotGatewayVoiceState(client, guildId);
|
||||
if (!gatewayState) return false;
|
||||
|
||||
const playerChannel = String(player._channelId ?? player._home247Channel ?? "").replace(/\D/g, "");
|
||||
const playerChannel = cleanId(player._channelId ?? player._home247Channel);
|
||||
const gatewayChannel = gatewayState.channelId;
|
||||
|
||||
if (!playerChannel) return true;
|
||||
@@ -96,13 +125,19 @@ function isStaleGatewayPresence(client, player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a player's stale connection and respawn a fresh player, restoring queue and playback.
|
||||
* @param {object} ctx - The bot context (this)
|
||||
* @param {import("../src/Player.mjs").default} player
|
||||
* @returns {Promise<{ success: boolean, reason?: string, channelId?: string, roomConnected?: boolean, roomState?: string, resumedPlayback?: boolean }>}
|
||||
*/
|
||||
async function forceRejoinPlayer(ctx, player) {
|
||||
const channelId = player._channelId ?? player._home247Channel;
|
||||
const guildId = player._guildId ?? player._resolveGuildId?.();
|
||||
if (!channelId || !guildId) return { success: false, reason: "no channel or guild id" };
|
||||
|
||||
const cleanChannelId = String(channelId).replace(/\D/g, "");
|
||||
const cleanGuildId = String(guildId).replace(/\D/g, "");
|
||||
const cleanChannelId = cleanId(channelId);
|
||||
const cleanGuildId = cleanId(guildId);
|
||||
|
||||
const currentTrack = player.queue?.getCurrent();
|
||||
const queueTracks = player.queue?.data ? [...player.queue.data] : [];
|
||||
@@ -118,7 +153,7 @@ async function forceRejoinPlayer(ctx, player) {
|
||||
|
||||
const altIds = [player._channelId, player._home247Channel]
|
||||
.filter(Boolean)
|
||||
.map(id => String(id).replace(/\D/g, ""))
|
||||
.map(id => cleanId(id))
|
||||
.filter(id => id !== cleanChannelId);
|
||||
for (const altId of altIds) {
|
||||
ctx.players.playerMap.delete(altId);
|
||||
@@ -135,16 +170,16 @@ async function forceRejoinPlayer(ctx, player) {
|
||||
|
||||
const revoiceConn = ctx.revoice?.connections?.get(cleanChannelId);
|
||||
if (revoiceConn) {
|
||||
try { await ctx.revoice._destroyStaleConnection(cleanChannelId, revoiceConn); } catch (_) {}
|
||||
try { await ctx.revoice._destroyStaleConnection(cleanChannelId, revoiceConn); } catch(e) { }
|
||||
} else if (player.connection) {
|
||||
try { player.connection.removeAllListeners(); } catch (_) {}
|
||||
try { ctx.revoice?._leaveGateway?.(cleanChannelId, cleanGuildId); } catch (_) {}
|
||||
try { ctx.revoice?.deleteConnection?.(cleanChannelId); } catch (_) {}
|
||||
try { await player.connection.disconnect(); } catch (_) {}
|
||||
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 { await player.leave(); } catch (_) {}
|
||||
try { player.destroy(); } catch (_) {}
|
||||
try { await player.leave(); } catch(e) { }
|
||||
try { player.destroy(); } catch(e) { }
|
||||
|
||||
await new Promise(r => setTimeout(r, REJOIN_DELAY_MS));
|
||||
|
||||
@@ -160,7 +195,7 @@ async function forceRejoinPlayer(ctx, player) {
|
||||
newPlayer.queue.current = null;
|
||||
await newPlayer.playNext();
|
||||
if (wasPaused) newPlayer.pause();
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
}
|
||||
|
||||
if (wasAutoplay) newPlayer._autoplay = true;
|
||||
@@ -189,6 +224,12 @@ export const command = new CommandBuilder()
|
||||
.addChoices("voice", "voice-rejoin", "247-rejoin")
|
||||
.setRequired(true));
|
||||
|
||||
/**
|
||||
* Execute the debug 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) {
|
||||
switch (data.get("target").value) {
|
||||
case "247-rejoin": {
|
||||
@@ -197,7 +238,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (channels247.length === 0) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0xFFAA00)
|
||||
.setColor(WARN_COLOR)
|
||||
.setTitle("Debug — 24/7 Rejoin")
|
||||
.setDescription("No 24/7 channels found in the player map.")
|
||||
;
|
||||
@@ -214,7 +255,7 @@ export async function run(msg, data) {
|
||||
const [cid, player] = channels247[i];
|
||||
const channel = this.client.channels.get(cid);
|
||||
const gId = player._guildId ?? channel?.guildId;
|
||||
const guild = gId ? this.client.guilds.get(String(gId).replace(/\D/g, "")) : null;
|
||||
const guild = gId ? this.client.guilds.get(cleanId(gId)) : null;
|
||||
const label = `${guild?.name ?? "unknown"} / #${channel?.name ?? cid}`;
|
||||
const ghost = isGhostConnection(player) ? " 👻GHOST" : "";
|
||||
const roomLabel = player.connection?.room ? roomStateLabel(player.connection.room) : "none";
|
||||
@@ -223,7 +264,7 @@ export async function run(msg, data) {
|
||||
}
|
||||
|
||||
const statusEmbed = new EmbedBuilder()
|
||||
.setColor(0xFFAA00)
|
||||
.setColor(WARN_COLOR)
|
||||
.setTitle("Debug — 24/7 Rejoin")
|
||||
.setDescription(statusLines.join("\n").slice(0, 4096))
|
||||
;
|
||||
@@ -235,7 +276,7 @@ export async function run(msg, data) {
|
||||
const [cid, player] = channels247[i];
|
||||
const channel = this.client.channels.get(cid);
|
||||
const gId = player._guildId ?? channel?.guildId;
|
||||
const guild = gId ? this.client.guilds.get(String(gId).replace(/\D/g, "")) : null;
|
||||
const guild = gId ? this.client.guilds.get(cleanId(gId)) : null;
|
||||
const label = `${guild?.name ?? "unknown"} / #${channel?.name ?? cid}`;
|
||||
|
||||
const result = await forceRejoinPlayer(this, player);
|
||||
@@ -274,7 +315,7 @@ export async function run(msg, data) {
|
||||
resultLines.push("", `⚠️ **${failedCount}** channel(s) could not be restored.`);
|
||||
}
|
||||
|
||||
const finalColor = failedCount === 0 ? 0x00CC66 : 0xFF4444;
|
||||
const finalColor = failedCount === 0 ? SUCCESS_COLOR : DANGER_COLOR;
|
||||
const finalEmbed = new EmbedBuilder()
|
||||
.setColor(finalColor)
|
||||
.setTitle("Debug — 24/7 Rejoin")
|
||||
@@ -296,7 +337,7 @@ export async function run(msg, data) {
|
||||
? `\n\n💡 No ghosts auto-detected, but 24/7 channels with dead WebSockets may still report as "connected".\nUse \`%debug 247-rejoin\` to force-rejoin all 24/7 channels.`
|
||||
: "";
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x00CC66)
|
||||
.setColor(SUCCESS_COLOR)
|
||||
.setTitle("Debug — Voice Rejoin")
|
||||
.setDescription(`No ghost connections found. All voice connections appear healthy.${hintLine}`)
|
||||
;
|
||||
@@ -313,7 +354,7 @@ export async function run(msg, data) {
|
||||
const [cid, player] = ghostEntries[i];
|
||||
const channel = this.client.channels.get(cid);
|
||||
const gId = player._guildId ?? channel?.guildId;
|
||||
const guild = gId ? this.client.guilds.get(String(gId).replace(/\D/g, "")) : null;
|
||||
const guild = gId ? this.client.guilds.get(cleanId(gId)) : null;
|
||||
const label = `${guild?.name ?? "unknown"} / #${channel?.name ?? cid}`;
|
||||
const is247 = player._home247Channel ? "yes" : "no";
|
||||
const hasTrack = player.queue?.getCurrent() ? "yes" : "no";
|
||||
@@ -321,7 +362,7 @@ export async function run(msg, data) {
|
||||
}
|
||||
|
||||
const statusEmbed = new EmbedBuilder()
|
||||
.setColor(0xFFAA00)
|
||||
.setColor(WARN_COLOR)
|
||||
.setTitle("Debug — Voice Rejoin")
|
||||
.setDescription(statusLines.join("\n").slice(0, 4096))
|
||||
;
|
||||
@@ -333,7 +374,7 @@ export async function run(msg, data) {
|
||||
const [cid, player] = ghostEntries[i];
|
||||
const channel = this.client.channels.get(cid);
|
||||
const gId = player._guildId ?? channel?.guildId;
|
||||
const guild = gId ? this.client.guilds.get(String(gId).replace(/\D/g, "")) : null;
|
||||
const guild = gId ? this.client.guilds.get(cleanId(gId)) : null;
|
||||
const label = `${guild?.name ?? "unknown"} / #${channel?.name ?? cid}`;
|
||||
|
||||
const result = await forceRejoinPlayer(this, player);
|
||||
@@ -372,7 +413,7 @@ export async function run(msg, data) {
|
||||
resultLines.push("", `⚠️ **${failedCount}** connection(s) could not be restored.`);
|
||||
}
|
||||
|
||||
const finalColor = failedCount === 0 ? 0x00CC66 : 0xFF4444;
|
||||
const finalColor = failedCount === 0 ? SUCCESS_COLOR : DANGER_COLOR;
|
||||
const finalEmbed = new EmbedBuilder()
|
||||
.setColor(finalColor)
|
||||
.setTitle("Debug — Voice Rejoin")
|
||||
@@ -388,7 +429,7 @@ export async function run(msg, data) {
|
||||
const servers = [...this.players.playerMap.entries()].map(([cid, s]) => {
|
||||
const channel = this.client.channels.get(cid);
|
||||
const guildId = s._guildId ?? channel?.guildId ?? channel?.guild_id;
|
||||
const guild = guildId ? this.client.guilds.get(String(guildId).replace(/\D/g, "")) : null;
|
||||
const guild = guildId ? this.client.guilds.get(cleanId(guildId)) : null;
|
||||
const conn = s.connection;
|
||||
const room = conn?.room;
|
||||
const ghost = isGhostConnection(s);
|
||||
@@ -520,7 +561,7 @@ export async function run(msg, data) {
|
||||
}
|
||||
|
||||
if (pages.length === 1) {
|
||||
const embedColor = ghostConnections.length > 0 ? 0xFF4444 : getGlobalColor();
|
||||
const embedColor = ghostConnections.length > 0 ? DANGER_COLOR : getGlobalColor();
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(embedColor)
|
||||
.setTitle(this.t(msg, "responses.debug.voiceTitle") + (ghostConnections.length > 0 ? ` — ${ghostConnections.length} Ghost(s) Detected!` : ""))
|
||||
@@ -540,7 +581,7 @@ export async function run(msg, data) {
|
||||
? this.t(msg, "responses._common.controlsExpired")
|
||||
: `${this.t(msg, "responses.eval.pageLabel", { page: pageIdx + 1, total: totalPages })} • ${this.t(msg, "responses.eval.navigateHint")}`;
|
||||
|
||||
const embedColor = (pageIdx === 0 && ghostConnections.length > 0) ? 0xFF4444 : getGlobalColor();
|
||||
const embedColor = (pageIdx === 0 && ghostConnections.length > 0) ? DANGER_COLOR : getGlobalColor();
|
||||
const titleSuffix = (pageIdx === 0 && ghostConnections.length > 0) ? ` — ${ghostConnections.length} Ghost(s) Detected!` : "";
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
@@ -565,7 +606,7 @@ export async function run(msg, data) {
|
||||
await replyMsg.message.removeAllReactions();
|
||||
} catch {
|
||||
for (const emoji of navEmojis) {
|
||||
try { await replyMsg.message.removeReaction(emoji); } catch {}
|
||||
try { await replyMsg.message.removeReaction(emoji); } catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+39
-4
@@ -1,9 +1,14 @@
|
||||
/**
|
||||
* @file eval command — Owner-only JavaScript code evaluation with sensitive-data redaction
|
||||
* @module commands/eval
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { inspect } from "node:util";
|
||||
import { ERROR_COLOR, EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
|
||||
|
||||
const EMOJI_REMOVE_TIMEOUT = 60000;
|
||||
|
||||
/**
|
||||
* Matches any key that *contains* one of these strings (case-insensitive).
|
||||
@@ -27,6 +32,13 @@ const RESTRICTED = [
|
||||
|
||||
const SCAN_DEPTH = 6;
|
||||
|
||||
/**
|
||||
* Check whether an object contains sensitive keys at any nesting level.
|
||||
* @param {object} obj - The object to scan
|
||||
* @param {number} [level=0] - Current recursion depth
|
||||
* @param {WeakSet} [visited=new WeakSet()] - Visited object tracker
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function hasSensitive(obj, level = 0, visited = new WeakSet()) {
|
||||
if (level >= SCAN_DEPTH || typeof obj !== "object" || obj === null) return false;
|
||||
if (visited.has(obj)) return false;
|
||||
@@ -38,6 +50,13 @@ function hasSensitive(obj, level = 0, visited = new WeakSet()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively redact sensitive keys from an object, replacing values with "[REDACTED]".
|
||||
* @param {object} obj - The object to scrub
|
||||
* @param {number} [level=0] - Current recursion depth
|
||||
* @param {WeakSet} [visited=new WeakSet()] - Visited object tracker
|
||||
* @returns {object} The scrubbed object (or the original if no changes were needed)
|
||||
*/
|
||||
function removeSensitive(obj, level = 0, visited = new WeakSet()) {
|
||||
if (level >= SCAN_DEPTH || typeof obj !== "object" || obj === null) return obj;
|
||||
if (visited.has(obj)) return "[Circular]";
|
||||
@@ -64,6 +83,11 @@ function removeSensitive(obj, level = 0, visited = new WeakSet()) {
|
||||
return modified ? newObj : obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Await a value if it is a Promise, then redact sensitive data and format for display.
|
||||
* @param {*} value - The value to clean and format
|
||||
* @returns {Promise<string>} Formatted, safe string representation
|
||||
*/
|
||||
async function clean(value) {
|
||||
if (value instanceof Promise) value = await value;
|
||||
|
||||
@@ -85,6 +109,11 @@ async function clean(value) {
|
||||
.replace(/@/g, "@\u200b") || "undefined";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a code string is a single expression (no semicolons, blocks, or declarations).
|
||||
* @param {string} code - The code to inspect
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSingleExpression(code) {
|
||||
const trimmed = code.trim();
|
||||
|
||||
@@ -144,6 +173,12 @@ export const command = new CommandBuilder()
|
||||
.setRequired(true)
|
||||
);
|
||||
|
||||
/**
|
||||
* Execute the eval 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 expression = data.get("expression").value;
|
||||
|
||||
@@ -183,7 +218,7 @@ export async function run(msg, data) {
|
||||
else footerText += " " + this.t(msg, "responses.eval.deleteHint");
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(isError ? "#ff0000" : getGlobalColor())
|
||||
.setColor(isError ? ERROR_COLOR : getGlobalColor())
|
||||
.setTitle(title)
|
||||
.setDescription(desc)
|
||||
.setFooter({ text: footerText })
|
||||
@@ -210,7 +245,7 @@ export async function run(msg, data) {
|
||||
for (const emoji of navEmojis) {
|
||||
try {
|
||||
await replyMsg.message.removeReaction(emoji);
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -244,4 +279,4 @@ export async function run(msg, data) {
|
||||
});
|
||||
|
||||
resetTimer();
|
||||
}
|
||||
}
|
||||
+27
-8
@@ -1,7 +1,15 @@
|
||||
/**
|
||||
* @file filter command — Interactive audio filter picker with emoji-based toggling
|
||||
* @module commands/filter
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
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";
|
||||
|
||||
const NAV_EMOJIS = [PREV_EMOJI, NEXT_EMOJI, CANCEL_EMOJI];
|
||||
|
||||
const FILTERS = [
|
||||
{
|
||||
@@ -160,10 +168,6 @@ const FILTERS = [
|
||||
];
|
||||
|
||||
const PAGE_SIZE = 9;
|
||||
const PREV_EMOJI = "⬅️";
|
||||
const NEXT_EMOJI = "➡️";
|
||||
const CANCEL_EMOJI = "❌";
|
||||
const NAV_EMOJIS = [PREV_EMOJI, NEXT_EMOJI, CANCEL_EMOJI];
|
||||
|
||||
const SESSION_MS = 60_000;
|
||||
|
||||
@@ -195,6 +199,15 @@ export const command = new CommandBuilder()
|
||||
.setCategory("music")
|
||||
.addAliases("filters", "fx", "effect");
|
||||
|
||||
/**
|
||||
* Build the embed for a single page of the filter picker.
|
||||
* @param {Function} t - Translation function
|
||||
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
|
||||
* @param {number} page - Current page index (0-based)
|
||||
* @param {string[]} activeKeys - Currently active filter keys
|
||||
* @param {object} [current] - The currently playing track
|
||||
* @returns {import("@fluxerjs/core").EmbedBuilder}
|
||||
*/
|
||||
function buildPageEmbed(t, msg, page, activeKeys, current) {
|
||||
const totalPages = Math.ceil(FILTERS.length / PAGE_SIZE);
|
||||
const start = page * PAGE_SIZE;
|
||||
@@ -238,6 +251,12 @@ function buildPageEmbed(t, msg, page, activeKeys, current) {
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the filter 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) {
|
||||
const player = await this.getPlayer(msg, false, false, false);
|
||||
if (!player) return;
|
||||
@@ -267,14 +286,14 @@ export async function run(msg) {
|
||||
try {
|
||||
await menuMsg.message.react(emoji);
|
||||
await Utils.sleep(50);
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
}
|
||||
};
|
||||
|
||||
const removePageFilterEmojis = async (p) => {
|
||||
const pageEmojis = getPageItems(p).map(f => f.emoji);
|
||||
for (const emoji of pageEmojis) {
|
||||
try { await menuMsg.message.removeReaction(emoji); } catch (_) {}
|
||||
try { await menuMsg.message.removeReaction(emoji); } catch(e) { }
|
||||
}
|
||||
};
|
||||
|
||||
@@ -288,7 +307,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 (_) {}
|
||||
try { await menuMsg.message.removeReaction(emoji); } catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -442,4 +461,4 @@ export async function run(msg) {
|
||||
});
|
||||
|
||||
resetTimer();
|
||||
}
|
||||
}
|
||||
+16
-13
@@ -1,6 +1,10 @@
|
||||
/**
|
||||
* @file forceleave command — Force the bot to leave a voice channel (requires ManageChannels)
|
||||
* @module commands/forceleave
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { cleanId } from "../src/MessageHandler.mjs";
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("forceleave")
|
||||
@@ -14,23 +18,22 @@ export const command = new CommandBuilder()
|
||||
.setRequired(true)
|
||||
);
|
||||
|
||||
function embed(desc) {
|
||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
||||
}
|
||||
|
||||
function cleanId(value) {
|
||||
return String(value ?? "").replace(/\D/g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the forceleave 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 cid = cleanId(data.get("channelId").value);
|
||||
const targetChannel = this.client.channels.get(cid);
|
||||
if (!targetChannel) return msg.reply(embed(this.t(msg, "responses.forceleave.channelNotFound")));
|
||||
if (!targetChannel) return msg.reply(this.t(msg, "responses.forceleave.channelNotFound"));
|
||||
if (cleanId(msg.message?.guildId) !== cleanId(targetChannel.guildId))
|
||||
return msg.reply(embed(this.t(msg, "responses.forceleave.wrongServer")));
|
||||
return msg.reply(this.t(msg, "responses.forceleave.wrongServer"));
|
||||
const p = this.players.playerMap.get(cid)
|
||||
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cid);
|
||||
if (!p) return msg.reply(embed(this.t(msg, "responses.forceleave.playerNotFound")));
|
||||
if (!p.connection) return msg.reply(embed(this.t(msg, "responses.forceleave.playerNotInit")));
|
||||
if (!p) return msg.reply(this.t(msg, "responses.forceleave.playerNotFound"));
|
||||
if (!p.connection) return msg.reply(this.t(msg, "responses.forceleave.playerNotInit"));
|
||||
await this.players.leave(msg, cid);
|
||||
}
|
||||
+13
-2
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file invite command — Get the bot invite link and support server invite
|
||||
* @module commands/invite
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -8,6 +13,12 @@ export const command = new CommandBuilder()
|
||||
.addAliases("addbot", "remix")
|
||||
.setCategory("util");
|
||||
|
||||
/**
|
||||
* Execute the invite command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @param {Map<string, {value: *}>} data - Slash-command options map
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(message) {
|
||||
const description = this.t(message, "responses.invite.description");
|
||||
|
||||
@@ -25,5 +36,5 @@ export async function run(message) {
|
||||
|
||||
await message.reply({
|
||||
embeds: [embed]
|
||||
});
|
||||
}
|
||||
}).catch(() => {});
|
||||
}
|
||||
+29
-23
@@ -1,23 +1,23 @@
|
||||
/**
|
||||
* @file join command — Make the bot join a voice channel and initialise a player
|
||||
* @module commands/join
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { getGlobalColor, cleanId, getMessageGuildId } from "../src/MessageHandler.mjs";
|
||||
import { logger } from "../src/constants/Logger.mjs";
|
||||
import Player from "../src/Player.mjs";
|
||||
|
||||
function getGuildId(message) {
|
||||
return message?.channel?.guildId
|
||||
?? message?.channel?.guild?.id
|
||||
?? message?.message?.guildId
|
||||
?? message?.message?.guild?.id
|
||||
?? message?.channel?.server_id
|
||||
?? message?.channel?.serverId
|
||||
?? null;
|
||||
}
|
||||
|
||||
function cleanId(value) {
|
||||
return String(value ?? "").replace(/\D/g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Join a voice channel, create a Player, and register event listeners.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @param {string} cid - The voice channel ID to join
|
||||
* @param {Function} [cb] - Callback invoked with the player on success
|
||||
* @param {Function} [ecb] - Callback invoked on error
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||
const cleanChannelId = cleanId(cid);
|
||||
if (!this.client.channels.has(cleanChannelId)) {
|
||||
@@ -54,9 +54,9 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||
});
|
||||
|
||||
p.on("autoleave", () => {
|
||||
const activeChannelId = String(p._channelId ?? cid).replace(/\D/g, "") || cid;
|
||||
const homeChannelId = String(p._home247Channel ?? activeChannelId).replace(/\D/g, "") || activeChannelId;
|
||||
const guildId = getGuildId(message);
|
||||
const activeChannelId = cleanId(p._channelId ?? cid) || cid;
|
||||
const homeChannelId = cleanId(p._home247Channel ?? activeChannelId) || activeChannelId;
|
||||
const guildId = getMessageGuildId(message);
|
||||
|
||||
const is247 = (() => {
|
||||
try {
|
||||
@@ -106,13 +106,13 @@ export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||
});
|
||||
|
||||
p.on("message", m => {
|
||||
const guildId = getGuildId(message);
|
||||
const guildId = getMessageGuildId(message);
|
||||
const raw = this.settingsMgr?.getServer?.(guildId)?.get("songAnnouncements");
|
||||
const disabled = raw === false || raw === 0 ||
|
||||
["false","0","no","off","disable"].includes(String(raw).toLowerCase().trim());
|
||||
if (disabled) return;
|
||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(m);
|
||||
message.channel.send({ embeds: [embed] });
|
||||
message.channel.send({ embeds: [embed] }).catch(() => {});
|
||||
});
|
||||
|
||||
this.players._pendingJoins.add(cleanChannelId);
|
||||
@@ -147,6 +147,12 @@ export const command = new CommandBuilder()
|
||||
.setRequired(false)
|
||||
);
|
||||
|
||||
/**
|
||||
* Execute the join command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @param {Map<string, {value: *}>} data - Slash-command options map
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(message, data) {
|
||||
const rawArg = data?.get?.("channel")?.value?.trim?.() ?? null;
|
||||
|
||||
@@ -160,7 +166,7 @@ export async function run(message, data) {
|
||||
} else if (idMatch) {
|
||||
resolvedId = idMatch[1];
|
||||
} else {
|
||||
const guildId = cleanId(getGuildId(message));
|
||||
const guildId = cleanId(getMessageGuildId(message));
|
||||
const allChannels = [
|
||||
...(this.client?.channels?.values?.() ?? [])
|
||||
];
|
||||
@@ -182,10 +188,10 @@ export async function run(message, data) {
|
||||
return this.players.initPlayer(message, resolvedId);
|
||||
}
|
||||
|
||||
const cid = this.players.checkVoiceChannels(message);
|
||||
const { channelId: cid } = await this.players.checkVoiceChannels(message);
|
||||
|
||||
if (!cid) {
|
||||
const prefix = this.handler.getPrefix(getGuildId(message));
|
||||
const prefix = this.handler.getPrefix(getMessageGuildId(message));
|
||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||
.setDescription(this.t(message, "responses.join.noVoiceChannel", { prefix }));
|
||||
return message.reply({ embeds: [embed] });
|
||||
@@ -197,4 +203,4 @@ export async function run(message, data) {
|
||||
export const exportDef = {
|
||||
name: "joinChannel",
|
||||
object: joinChannel
|
||||
};
|
||||
};
|
||||
+90
-78
@@ -1,10 +1,15 @@
|
||||
/**
|
||||
* @file lastfm command — Link Last.fm accounts, scrobble, view profiles, leaderboards, and more
|
||||
* @module commands/lastfm
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { Utils } from "../src/Utils.mjs";
|
||||
import { PROVIDER_CHOICES } from "../src/constants/providers.mjs";
|
||||
import { ERROR_COLOR, EMOJI_REMOVE_TIMEOUT } from "../src/constants/UI.mjs";
|
||||
|
||||
const EMOJI_REMOVE_TIMEOUT = 60_000;
|
||||
|
||||
const VALID_PERIODS = ["7day", "1month", "3month", "6month", "12month", "overall"];
|
||||
|
||||
@@ -46,7 +51,7 @@ export const command = new CommandBuilder()
|
||||
function notConfigured(ctx, msg) {
|
||||
return {
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor("#ff0000")
|
||||
.setColor(ERROR_COLOR)
|
||||
.setDescription(ctx.t(msg, "responses.lastfm.notConfigured"))]
|
||||
};
|
||||
}
|
||||
@@ -113,7 +118,7 @@ async function getGuildLinkedUsers(guild) {
|
||||
if (userId && !m.user?.bot) memberIds.push(String(userId));
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
return memberIds;
|
||||
}
|
||||
|
||||
@@ -142,7 +147,8 @@ function extractPeriod(data, msg) {
|
||||
* Shared between `%lastfm play <cat>` and `%play lastfm:<cat>`.
|
||||
*
|
||||
* @param {object} ctx - The command `this` context (has .lastfm, .getPlayer, .handler, .t)
|
||||
* @param {object} msg - The message object
|
||||
* @param {import("../src/MessageHandler.mjs").Message} msg - The message object
|
||||
* @param {string} userId - The Discord user ID
|
||||
* @param {string} category - "loved", "top", "recent", or "playlist"
|
||||
* @param {object} [options]
|
||||
* @param {string} [options.period] - Period for top tracks
|
||||
@@ -161,7 +167,7 @@ export async function playLastFmCategory(ctx, msg, userId, category, options = {
|
||||
const validCategories = [...SIMPLE_CATEGORIES, "playlist"];
|
||||
if (!validCategories.includes(category)) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
`❌ Unknown category \`${category}\`. Use \`loved\`, \`top\`, \`recent\`, \`albums\`, \`artists\`, or \`playlist\`.`
|
||||
)]
|
||||
});
|
||||
@@ -169,7 +175,7 @@ export async function playLastFmCategory(ctx, msg, userId, category, options = {
|
||||
|
||||
if (category === "playlist" && !options.playlistId) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
`❌ Specify a playlist number. Use \`${prefix}lastfm playlists\` to see your playlists, then \`${prefix}lastfm play playlist <number>\`.`
|
||||
)]
|
||||
});
|
||||
@@ -201,7 +207,7 @@ export async function playLastFmCategory(ctx, msg, userId, category, options = {
|
||||
} catch (err) {
|
||||
const errMsg = err.message === "NOT_LINKED"
|
||||
? notLinked(ctx, msg, prefix)
|
||||
: { embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(ctx.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
: { embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(ctx.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
if (statusMsg) statusMsg.edit(errMsg).catch(() => msg.reply(errMsg));
|
||||
else msg.reply(errMsg);
|
||||
return;
|
||||
@@ -328,6 +334,12 @@ function parsePlayArgs(msg, data) {
|
||||
return { category: "" };
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the lastfm 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 lastfm = this.lastfm;
|
||||
if (!lastfm || !lastfm.enabled) return msg.reply(notConfigured(this, msg));
|
||||
@@ -353,7 +365,7 @@ export async function run(msg, data) {
|
||||
token = await lastfm.getAuthToken();
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.tokenFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.tokenFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -395,7 +407,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!tokenValue) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.confirmUsage", { prefix }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.confirmUsage", { prefix }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -404,7 +416,7 @@ export async function run(msg, data) {
|
||||
session = await lastfm.getSession(tokenValue);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.confirmFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.confirmFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -453,7 +465,7 @@ export async function run(msg, data) {
|
||||
recentData = await lastfm.getRecentTracks(userId, 1);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -484,7 +496,7 @@ export async function run(msg, data) {
|
||||
info = await lastfm.getUserInfo(profileUserId);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -514,7 +526,7 @@ export async function run(msg, data) {
|
||||
playlists = await lastfm.getPlaylists(userId);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -546,7 +558,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (parsed.invalidCategory) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
`❌ \`${parsed.resolveProvider}:${parsed.invalidCategory}\` is not valid. Non-Last.fm providers only support \`top\`.\nUse \`${prefix}lastfm play ${parsed.resolveProvider}\` or \`${prefix}lastfm play ${parsed.resolveProvider}:top\` instead.\nFor other categories, use Last.fm as the resolve provider: \`${prefix}lastfm play lf:${parsed.invalidCategory}\``
|
||||
)]
|
||||
});
|
||||
@@ -557,7 +569,7 @@ export async function run(msg, data) {
|
||||
? `\n\n💡 \`${prefix}lastfm play ${parsed.resolveProvider}:<category>\` — Specify a category after the provider:`
|
||||
: "";
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription([
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription([
|
||||
`❌ Usage: \`${prefix}lastfm play <category>\``,
|
||||
``,
|
||||
`**Categories:**`,
|
||||
@@ -607,7 +619,7 @@ export async function run(msg, data) {
|
||||
tracks = await lastfm.getLovedTracks(userId, 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -631,7 +643,7 @@ export async function run(msg, data) {
|
||||
tracks = await lastfm.getTopTracks(userId, period, 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -652,7 +664,7 @@ export async function run(msg, data) {
|
||||
lb = await lastfm.getLeaderboard(0, 10);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -693,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 {}
|
||||
try { await replyMsg.message.removeReaction(emoji); } catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -727,7 +739,7 @@ export async function run(msg, data) {
|
||||
try {
|
||||
lb = await lastfm.getLeaderboard(currentPage, 10);
|
||||
} catch {
|
||||
/* keep previous data */
|
||||
|
||||
}
|
||||
|
||||
await replyMsg.edit(buildPage(currentPage)).catch(() => {});
|
||||
@@ -746,7 +758,7 @@ export async function run(msg, data) {
|
||||
tracks = await lastfm.getRecentTracks(userId, 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -770,7 +782,7 @@ export async function run(msg, data) {
|
||||
artists = await lastfm.getTopArtists(userId, period, 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -809,7 +821,7 @@ export async function run(msg, data) {
|
||||
const track = pLove.queue?.getCurrent();
|
||||
if (!track) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.nothingPlayingLove"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.nothingPlayingLove"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -823,7 +835,7 @@ export async function run(msg, data) {
|
||||
});
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.loveFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.loveFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -837,7 +849,7 @@ export async function run(msg, data) {
|
||||
const track = pUnlove.queue?.getCurrent();
|
||||
if (!track) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.nothingPlayingUnlove"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.nothingPlayingUnlove"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -851,7 +863,7 @@ export async function run(msg, data) {
|
||||
});
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.unloveFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.unloveFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -875,7 +887,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!artistName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.nothingPlayingNoArtist"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.nothingPlayingNoArtist"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -895,7 +907,7 @@ export async function run(msg, data) {
|
||||
try {
|
||||
listeners = await lastfm.getWhoKnows(artistName, memberIds);
|
||||
} catch (err) {
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
if (statusMsg) statusMsg.edit(errEmbed).catch(() => msg.reply(errEmbed));
|
||||
else msg.reply(errEmbed);
|
||||
return;
|
||||
@@ -951,7 +963,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!artistName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
this.t(msg, "responses.lastfm.noArtistSpecified")
|
||||
)]
|
||||
});
|
||||
@@ -962,13 +974,13 @@ export async function run(msg, data) {
|
||||
info = await lastfm.getArtistInfo(artistName, userId);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
if (!info) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.artistNotFound", { artist: artistName }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.artistNotFound", { artist: artistName }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1043,7 +1055,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!albumName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
this.t(msg, "responses.lastfm.noAlbumSpecified")
|
||||
)]
|
||||
});
|
||||
@@ -1054,13 +1066,13 @@ export async function run(msg, data) {
|
||||
info = await lastfm.getAlbumInfo(artistName || "", albumName, userId);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
if (!info) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.albumNotFound", { album: albumName }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.albumNotFound", { album: albumName }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1132,13 +1144,13 @@ export async function run(msg, data) {
|
||||
artistName = searchResult.artist;
|
||||
trackName = searchResult.name;
|
||||
}
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
|
||||
if (!artistName || !trackName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
this.t(msg, "responses.lastfm.noTrackSpecified")
|
||||
)]
|
||||
});
|
||||
@@ -1149,13 +1161,13 @@ export async function run(msg, data) {
|
||||
info = await lastfm.getTrackInfo(artistName, trackName, userId);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
if (!info) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.trackNotFound", { track: trackName, artist: artistName }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.trackNotFound", { track: trackName, artist: artistName }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1215,7 +1227,7 @@ export async function run(msg, data) {
|
||||
let similarTracks = [];
|
||||
try {
|
||||
similarTracks = await lastfm.getSimilarTracks(artistName, trackName, 5);
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
|
||||
if (similarTracks.length) {
|
||||
const simStr = similarTracks.map(t => {
|
||||
@@ -1242,7 +1254,7 @@ export async function run(msg, data) {
|
||||
albums = await lastfm.getTopAlbums(userId, period, 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1288,7 +1300,7 @@ export async function run(msg, data) {
|
||||
tags = await lastfm.getUserTopTags(userId, 20);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1319,7 +1331,7 @@ export async function run(msg, data) {
|
||||
const tagName = data.get("token")?.value;
|
||||
if (!tagName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
this.t(msg, "responses.lastfm.tagProvideName", { prefix })
|
||||
)]
|
||||
});
|
||||
@@ -1337,13 +1349,13 @@ export async function run(msg, data) {
|
||||
]);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
if (!tagInfo) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.tagNotFound", { tag: tagName }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.tagNotFound", { tag: tagName }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1392,7 +1404,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!targetUserId) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
this.t(msg, "responses.lastfm.compareSpecifyUser", { prefix })
|
||||
)]
|
||||
});
|
||||
@@ -1401,7 +1413,7 @@ export async function run(msg, data) {
|
||||
const targetUser = await lastfm.getUser(targetUserId);
|
||||
if (!targetUser) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
this.t(msg, "responses.lastfm.compareUserNotLinked")
|
||||
)]
|
||||
});
|
||||
@@ -1412,13 +1424,13 @@ export async function run(msg, data) {
|
||||
comparison = await lastfm.compareUsers(userId, targetUserId);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
if (!comparison) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.compareFailed"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.compareFailed"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1455,7 +1467,7 @@ export async function run(msg, data) {
|
||||
const current = extractCurrentTrack(pCover);
|
||||
if (!current || !current.name) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.coverNothingPlaying"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.coverNothingPlaying"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1473,7 +1485,7 @@ export async function run(msg, data) {
|
||||
coverUrl = albumInfo.image;
|
||||
albumTitle = `${albumInfo.name} by ${albumInfo.artist}`;
|
||||
}
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
}
|
||||
|
||||
if (!coverUrl) {
|
||||
@@ -1486,7 +1498,7 @@ export async function run(msg, data) {
|
||||
albumTitle = trackInfo.album.title;
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
}
|
||||
|
||||
if (!coverUrl) {
|
||||
@@ -1509,7 +1521,7 @@ export async function run(msg, data) {
|
||||
const guild = msg.message?.guild ?? msg.message?.member?.guild;
|
||||
if (!guild) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.refreshFailed"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.refreshFailed"))]
|
||||
});
|
||||
}
|
||||
let count = 0;
|
||||
@@ -1555,7 +1567,7 @@ export async function run(msg, data) {
|
||||
try {
|
||||
affinityResults = await lastfm.getAffinity(memberIds, 10);
|
||||
} catch (err) {
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
if (statusMsg) statusMsg.edit(errEmbed).catch(() => msg.reply(errEmbed));
|
||||
else msg.reply(errEmbed);
|
||||
return;
|
||||
@@ -1606,7 +1618,7 @@ export async function run(msg, data) {
|
||||
try {
|
||||
crowns = await lastfm.getCrowns(userId, memberIds);
|
||||
} catch (err) {
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
if (statusMsg) statusMsg.edit(errEmbed).catch(() => msg.reply(errEmbed));
|
||||
else msg.reply(errEmbed);
|
||||
return;
|
||||
@@ -1680,13 +1692,13 @@ export async function run(msg, data) {
|
||||
artistName = searchResult.artist;
|
||||
trackName = searchResult.name;
|
||||
}
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
|
||||
if (!artistName || !trackName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.noTrackSpecified"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.noTrackSpecified"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1704,7 +1716,7 @@ export async function run(msg, data) {
|
||||
try {
|
||||
listeners = await lastfm.getWhoKnowsTrack(artistName, trackName, memberIds);
|
||||
} catch (err) {
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
if (statusMsg) statusMsg.edit(errEmbed).catch(() => msg.reply(errEmbed));
|
||||
else msg.reply(errEmbed);
|
||||
return;
|
||||
@@ -1767,7 +1779,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!albumName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.noAlbumSpecified"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.noAlbumSpecified"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1785,7 +1797,7 @@ export async function run(msg, data) {
|
||||
try {
|
||||
listeners = await lastfm.getWhoKnowsAlbum(artistName || "", albumName, memberIds);
|
||||
} catch (err) {
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
const errEmbed = { embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))] };
|
||||
if (statusMsg) statusMsg.edit(errEmbed).catch(() => msg.reply(errEmbed));
|
||||
else msg.reply(errEmbed);
|
||||
return;
|
||||
@@ -1837,7 +1849,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!artistName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.noArtistSpecified"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.noArtistSpecified"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1846,7 +1858,7 @@ export async function run(msg, data) {
|
||||
tags = await lastfm.getArtistTopTags(artistName, 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1897,7 +1909,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!albumName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.noAlbumSpecified"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.noAlbumSpecified"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1906,7 +1918,7 @@ export async function run(msg, data) {
|
||||
tags = await lastfm.getAlbumTopTags(artistName || "", albumName, 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1957,13 +1969,13 @@ export async function run(msg, data) {
|
||||
artistName = searchResult.artist;
|
||||
trackName = searchResult.name;
|
||||
}
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
|
||||
if (!artistName || !trackName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.noTrackSpecified"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.noTrackSpecified"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1972,7 +1984,7 @@ export async function run(msg, data) {
|
||||
tags = await lastfm.getTrackTopTags(artistName, trackName, 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2008,7 +2020,7 @@ export async function run(msg, data) {
|
||||
friends = await lastfm.getUserFriends(userId, 20);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2060,7 +2072,7 @@ export async function run(msg, data) {
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2104,7 +2116,7 @@ export async function run(msg, data) {
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2138,7 +2150,7 @@ export async function run(msg, data) {
|
||||
const tokenTextG = data.get("token")?.value?.trim() ?? "";
|
||||
if (!tokenTextG) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Provide a query like \`artists <country>\` or \`tracks <country>\`. Example: \`${prefix}lastfm geo artists united states\`.`)]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(`❌ Provide a query like \`artists <country>\` or \`tracks <country>\`. Example: \`${prefix}lastfm geo artists united states\`.`)]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2156,7 +2168,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!country) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Please specify a country name. Example: \`${prefix}lastfm geo artists united states\`.`)]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(`❌ Please specify a country name. Example: \`${prefix}lastfm geo artists united states\`.`)]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2173,7 +2185,7 @@ export async function run(msg, data) {
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2206,7 +2218,7 @@ export async function run(msg, data) {
|
||||
const tagName = data.get("token")?.value;
|
||||
if (!tagName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Provide a tag name via the token option. Example: \`${prefix}lastfm tagalbums rock\``)]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(`❌ Provide a tag name via the token option. Example: \`${prefix}lastfm tagalbums rock\``)]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2215,7 +2227,7 @@ export async function run(msg, data) {
|
||||
albums = await lastfm.getTagTopAlbums(tagName.trim(), 15);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2265,7 +2277,7 @@ export async function run(msg, data) {
|
||||
|
||||
if (!artistName) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.noArtistSpecified"))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.noArtistSpecified"))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2274,7 +2286,7 @@ export async function run(msg, data) {
|
||||
recentTracks = await lastfm.getRecentTracks(userId, 200);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2311,7 +2323,7 @@ export async function run(msg, data) {
|
||||
const query = data.get("token")?.value;
|
||||
if (!query) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(`❌ Provide a search query via the token option. Example: \`${prefix}lastfm search radiohead\``)]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(`❌ Provide a search query via the token option. Example: \`${prefix}lastfm search radiohead\``)]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2324,7 +2336,7 @@ export async function run(msg, data) {
|
||||
]);
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.lastfm.fetchFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+22
-19
@@ -1,7 +1,11 @@
|
||||
/**
|
||||
* @file leave.mjs — Leave the current voice channel and stop playback
|
||||
* @module commands.leave
|
||||
*/
|
||||
|
||||
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 { getGlobalColor, cleanId } from "../src/MessageHandler.mjs";
|
||||
import { get247ChannelMode } from "../src/constants/Helpers247.mjs";
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
@@ -15,13 +19,6 @@ export const command = new CommandBuilder()
|
||||
.setRequired(false)
|
||||
);
|
||||
|
||||
function embed(desc) {
|
||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
||||
}
|
||||
|
||||
function cleanId(value) {
|
||||
return String(value ?? "").replace(/\D/g, "");
|
||||
}
|
||||
|
||||
function resolvePlayerGuildId(player, mapKey, client) {
|
||||
const direct = cleanId(player?._guildId);
|
||||
@@ -32,6 +29,12 @@ function resolvePlayerGuildId(player, mapKey, client) {
|
||||
return cleanId(ch?.guildId ?? ch?.guild?.id ?? ch?.server_id ?? ch?.serverId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the leave 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 guildId = msg.channel?.guild?.id
|
||||
?? msg.channel?.guildId
|
||||
@@ -54,24 +57,24 @@ export async function run(msg, data) {
|
||||
if (specifiedChannel) {
|
||||
targetChannelId = cleanId(specifiedChannel);
|
||||
} else {
|
||||
const userChannelId = this.players.checkVoiceChannels(msg);
|
||||
const { channelId: userChannelId } = await this.players.checkVoiceChannels(msg);
|
||||
if (userChannelId) targetChannelId = cleanId(userChannelId);
|
||||
}
|
||||
|
||||
if (!targetChannelId) {
|
||||
if (guildPlayers.length === 0) {
|
||||
return msg.reply(embed(this.t(msg, "responses.leave.notInVoice")));
|
||||
return msg.reply(this.t(msg, "responses.leave.notInVoice"));
|
||||
}
|
||||
const channelList = guildPlayers.map(([mapKey, p]) => {
|
||||
const id = cleanId(p._channelId ?? mapKey);
|
||||
return id ? `<#${id}>` : "`unknown`";
|
||||
});
|
||||
return msg.reply(embed(
|
||||
return msg.reply(
|
||||
this.t(msg, "responses.leave.specifyChannel", {
|
||||
channels: channelList.map(c => `• ${c}`).join("\n"),
|
||||
prefix: this.handler.getPrefix(msg.message?.guildId ?? msg.channel?.guild?.id)
|
||||
})
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
const player = this.players.playerMap.get(targetChannelId)
|
||||
@@ -82,21 +85,21 @@ export async function run(msg, data) {
|
||||
|
||||
if (!player) {
|
||||
if (guildPlayers.length === 0) {
|
||||
return msg.reply(embed(this.t(msg, "responses.leave.notInVoice")));
|
||||
return msg.reply(this.t(msg, "responses.leave.notInVoice"));
|
||||
}
|
||||
const channelList = guildPlayers.map(([mapKey, p]) => {
|
||||
const id = cleanId(p._channelId ?? mapKey);
|
||||
return id ? `<#${id}>` : "`unknown`";
|
||||
});
|
||||
return msg.reply(embed(
|
||||
return msg.reply(
|
||||
this.t(msg, "responses.leave.noPlayerInChannel", {
|
||||
channel: `<#${targetChannelId}>`,
|
||||
channels: channelList.map(c => `• ${c}`).join("\n")
|
||||
})
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
if (!player?.connection) return msg.reply(embed(this.t(msg, "responses.leave.playerNotInit")));
|
||||
if (!player?.connection) return msg.reply(this.t(msg, "responses.leave.playerNotInit"));
|
||||
|
||||
const activeChannelId = cleanId(player._channelId) || targetChannelId;
|
||||
const homeChannelId = cleanId(player._home247Channel) || activeChannelId;
|
||||
@@ -134,7 +137,7 @@ export async function run(msg, data) {
|
||||
player.destroy();
|
||||
|
||||
if (mode === "auto") {
|
||||
msg.reply(embed(this.t(msg, "responses.leave.leftRejoin247", { channel: targetChannelId, prefix })));
|
||||
msg.reply(this.t(msg, "responses.leave.leftRejoin247", { channel: targetChannelId, prefix }));
|
||||
const rejoinDelay = this.config?.timers?.leave247RejoinDelay ?? 5000;
|
||||
setTimeout(() => {
|
||||
if (this._spawnPlayer) {
|
||||
@@ -144,7 +147,7 @@ export async function run(msg, data) {
|
||||
}
|
||||
}, rejoinDelay);
|
||||
} else {
|
||||
msg.reply(embed(this.t(msg, "responses.leave.left247On", { prefix })));
|
||||
msg.reply(this.t(msg, "responses.leave.left247On", { prefix }));
|
||||
}
|
||||
} else {
|
||||
await this.leaveChannel(activeChannelId, guildId, msg);
|
||||
|
||||
+13
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file list.mjs — Display the current song queue with pagination
|
||||
* @module commands.list
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { QueuePaginator, getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
@@ -16,6 +21,12 @@ export const command = new CommandBuilder()
|
||||
.setRequired(false)
|
||||
);
|
||||
|
||||
/**
|
||||
* Execute the list command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @param {Map<string, {value: *}>>} data - Slash-command options map
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(message, data) {
|
||||
const p = await this.getPlayer(message);
|
||||
if (!p) return;
|
||||
@@ -85,5 +96,6 @@ export async function run(message, data) {
|
||||
|
||||
new QueuePaginator(message, this.messages, this.client)
|
||||
.setTimeout(SESSION_MS)
|
||||
.send(buildEmbed, totalPages, startPage);
|
||||
.send(buildEmbed, totalPages, startPage)
|
||||
.catch(() => {});
|
||||
}
|
||||
+12
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file loop.mjs — Toggle loop mode for the queue or current track
|
||||
* @module commands.loop
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -12,6 +17,12 @@ export const command = new CommandBuilder()
|
||||
.setDescription("Specifies what loop should be toggled.", "options.loop.type")
|
||||
.setRequired(true));
|
||||
|
||||
/**
|
||||
* Execute the loop command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @param {Map<string, {value: *}>>} data - Slash-command options map
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(message, data) {
|
||||
const p = await this.getPlayer(message);
|
||||
if (!p) return;
|
||||
@@ -20,5 +31,5 @@ export async function run(message, data) {
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(res)
|
||||
;
|
||||
message.reply({ embeds: [embed] });
|
||||
message.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+15
-5
@@ -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(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-3
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file move.mjs — Move a track from one position to another in the queue
|
||||
* @module commands.move
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
@@ -16,13 +21,19 @@ export const command = new CommandBuilder()
|
||||
.setRequired(true)
|
||||
);
|
||||
|
||||
/**
|
||||
* Execute the move command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @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 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.");
|
||||
if (to == null || to < 1) return message.replyEmbed("Target position must be 1 or greater.");
|
||||
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(() => {});
|
||||
const res = p.move(from, to);
|
||||
message.replyEmbed(res);
|
||||
message.replyEmbed(res).catch(() => {});
|
||||
}
|
||||
+24
-7
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file np.mjs — Show now-playing information for the current track
|
||||
* @module commands.np
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -7,6 +12,11 @@ export const command = new CommandBuilder()
|
||||
.setDescription("Request the name and url of the currently playing song.", "commands.np")
|
||||
.addAliases("current", "nowplaying");
|
||||
|
||||
/**
|
||||
* Execute the np command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(msg) {
|
||||
const p = await this.getPlayer(msg);
|
||||
if (!p) return;
|
||||
@@ -17,12 +27,19 @@ export async function run(msg) {
|
||||
;
|
||||
const loadingMsg = await msg.reply({ embeds: [loadingEmbed] });
|
||||
|
||||
const data = await p.nowPlaying();
|
||||
try {
|
||||
const data = await p.nowPlaying();
|
||||
if (!data?.msg) {
|
||||
loadingMsg.edit({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses._common.nothingPlaying"))] }).catch(() => {});
|
||||
return;
|
||||
}
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(data.msg);
|
||||
if (data.image) embed.setThumbnail(data.image);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(data.msg);
|
||||
if (data.image) embed.setThumbnail(data.image);
|
||||
|
||||
loadingMsg.edit({ embeds: [embed] }).catch(() => {});
|
||||
loadingMsg.edit({ embeds: [embed] }).catch(() => {});
|
||||
} catch (e) {
|
||||
loadingMsg.edit({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses._common.nothingPlaying"))] }).catch(() => {});
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file pause.mjs — Pause the current playback
|
||||
* @module commands.pause
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -7,6 +12,11 @@ export const command = new CommandBuilder()
|
||||
.setDescription("Pause the playback in your voice channel", "commands.pause")
|
||||
.setCategory("music");
|
||||
|
||||
/**
|
||||
* Execute the pause 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);
|
||||
if (!p) return;
|
||||
@@ -15,5 +25,5 @@ export async function run(message) {
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(res)
|
||||
;
|
||||
message.reply({ embeds: [embed] });
|
||||
message.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+24
-21
@@ -1,16 +1,22 @@
|
||||
/**
|
||||
* @file play.mjs — Play a song, playlist, or Last.fm URL — the main music command with provider selection
|
||||
* @module commands.play
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { PROVIDER_CHOICES } from "../src/constants/providers.mjs";
|
||||
import { PROVIDER_CHOICES, parseInlineProvider } from "../src/constants/providers.mjs";
|
||||
import { playLastFmCategory } from "./lastfm.mjs";
|
||||
import { ERROR_COLOR } from "../src/constants/UI.mjs";
|
||||
|
||||
/**
|
||||
* Parse a Last.fm music URL and extract artist and track info.
|
||||
* Supports:
|
||||
* https:
|
||||
* https:
|
||||
* https:
|
||||
* https:
|
||||
* https://www.last.fm/music/Artist
|
||||
* https://www.last.fm/music/Artist/Track
|
||||
* https://www.last.fm/music/Artist/Album/Track
|
||||
* https://www.last.fm/music/Artist/_/Track
|
||||
*
|
||||
* @param {string} url
|
||||
* @returns {{ artist: string, track: string|null, album: string|null, url: string } | null}
|
||||
@@ -106,15 +112,6 @@ function parseLastFmSubProvider(query) {
|
||||
return { category: lower, resolveProvider: null };
|
||||
}
|
||||
|
||||
function parseInlineProvider(raw) {
|
||||
const match = raw.match(/^([a-z]+):\s*(.+)$/i);
|
||||
if (!match) return { provider: null, query: raw.trim() };
|
||||
const maybeProvider = match[1].toLowerCase();
|
||||
if (PROVIDER_CHOICES.includes(maybeProvider)) {
|
||||
return { provider: maybeProvider, query: match[2].trim() };
|
||||
}
|
||||
return { provider: null, query: raw.trim() };
|
||||
}
|
||||
|
||||
function parseLastFmTrackQuery(raw) {
|
||||
const value = String(raw ?? "").trim();
|
||||
@@ -179,6 +176,12 @@ export const command = new CommandBuilder()
|
||||
, true)
|
||||
.addAlias("p");
|
||||
|
||||
/**
|
||||
* Execute the play command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @param {Map<string, {value: *}>>} data - Slash-command options map
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(message, data) {
|
||||
const rawQuery = data.get("query").value;
|
||||
const flagProvider = data.get("provider")?.value;
|
||||
@@ -204,7 +207,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 {}
|
||||
try { statusMsg = await message.reply({ embeds: [searchEmbed] }); } catch(e) { }
|
||||
|
||||
const playQuery = `${parsed.track} ${parsed.artist}`.trim();
|
||||
const messages = p.play(playQuery, false, provider === "lastfm" || provider === "lf" ? "yt" : provider, lastfmTrackMeta);
|
||||
@@ -224,7 +227,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 {}
|
||||
try { statusMsg = await message.reply({ embeds: [searchEmbed] }); } catch(e) { }
|
||||
|
||||
const playQuery = parsed.artist;
|
||||
const messages = p.play(playQuery, false, provider === "lastfm" || provider === "lf" ? "yt" : provider);
|
||||
@@ -244,7 +247,7 @@ export async function run(message, data) {
|
||||
|
||||
if (parsed.invalidCategory) {
|
||||
return message.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
`❌ \`${resolveProvider}:${parsed.invalidCategory}\` is not valid. Non-Last.fm providers only support \`top\`.\nUse \`lastfm:${resolveProvider}\` or \`lastfm:${resolveProvider}:top\` instead.\nFor other categories, use Last.fm as the resolve provider: \`lastfm:lf:${parsed.invalidCategory}\``
|
||||
)]
|
||||
});
|
||||
@@ -252,7 +255,7 @@ export async function run(message, data) {
|
||||
|
||||
if (!lowerQuery && resolveProvider && (resolveProvider === "lf" || resolveProvider === "lastfm")) {
|
||||
return message.reply({
|
||||
embeds: [new EmbedBuilder().setColor("#ff0000").setDescription([
|
||||
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription([
|
||||
`❌ Specify a Last.fm category after \`lf:\``,
|
||||
``,
|
||||
`**Available categories:**`,
|
||||
@@ -295,14 +298,14 @@ export async function run(message, data) {
|
||||
`🔍 Searching Last.fm for **${query}**...`
|
||||
)]
|
||||
});
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
|
||||
try {
|
||||
searchResult = await lastfm.searchTrack(query);
|
||||
} catch {}
|
||||
} catch(e) { }
|
||||
|
||||
if (!searchResult) {
|
||||
const noResult = { embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(
|
||||
const noResult = { embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(
|
||||
`❌ No results found on Last.fm for **${query}**.`
|
||||
)] };
|
||||
if (statusMsg) statusMsg.edit(noResult).catch(() => message.reply(noResult));
|
||||
|
||||
+22
-21
@@ -1,7 +1,13 @@
|
||||
/**
|
||||
* @file player.mjs — Interactive player control panel with playback buttons and now-playing display
|
||||
* @module commands.player
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
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";
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("player")
|
||||
@@ -38,8 +44,12 @@ const PROGRESS = {
|
||||
end: "▕"
|
||||
};
|
||||
|
||||
const EMOJI_REMOVE_TIMEOUT = 60000;
|
||||
|
||||
/**
|
||||
* Execute the player command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(msg) {
|
||||
const player = await this.getPlayer(msg, false, false, false);
|
||||
if (!player) return;
|
||||
@@ -68,17 +78,8 @@ export async function run(msg) {
|
||||
? (current.duration.seconds ?? 0) * 1000
|
||||
: current.duration;
|
||||
|
||||
const progress = Math.min(elapsed / totalMs, 1);
|
||||
const barLength = 20;
|
||||
const filled = Math.floor(progress * barLength);
|
||||
const position = Math.min(Math.max(filled, 0), barLength - 1);
|
||||
const emptyCount = Math.max(barLength - position - 1, 0);
|
||||
|
||||
progressBar = PROGRESS.start +
|
||||
PROGRESS.filled.repeat(position) +
|
||||
(isPlaying ? PROGRESS.indicator : PROGRESS.filled) +
|
||||
PROGRESS.empty.repeat(emptyCount) +
|
||||
PROGRESS.end;
|
||||
const bar = Utils.progressBar(elapsed, totalMs, 20, PROGRESS.filled, PROGRESS.empty, isPlaying ? PROGRESS.indicator : PROGRESS.filled);
|
||||
progressBar = PROGRESS.start + bar + PROGRESS.end;
|
||||
|
||||
const elapsedStr = Utils.prettifyMS(elapsed);
|
||||
const totalStr = Utils.prettifyMS(totalMs);
|
||||
@@ -147,7 +148,7 @@ export async function run(msg) {
|
||||
try {
|
||||
await message.message.react(control.emoji);
|
||||
await Utils.sleep(50);
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ export async function run(msg) {
|
||||
for (const emoji of controlEmojis) {
|
||||
try {
|
||||
await message.message.removeReaction(emoji);
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -190,7 +191,7 @@ export async function run(msg) {
|
||||
for (const emoji of ["⬅️", "➡️", "❌"]) {
|
||||
try {
|
||||
await lyricsMsg.message.removeReaction(emoji);
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -233,9 +234,9 @@ export async function run(msg) {
|
||||
const closedEmbed = buildEmbed({
|
||||
message: this.t(msg, "responses.player.sessionClosed", { reason: reason !== "timeout" ? ` • ${reason}` : "" })
|
||||
});
|
||||
closedEmbed.color = getGlobalColor();
|
||||
closedEmbed.footer = { text: this.t(msg, "responses._common.sessionEnded") };
|
||||
closedEmbed.title = this.t(msg, "responses.player.inactiveTitle");
|
||||
closedEmbed.setColor(getGlobalColor());
|
||||
closedEmbed.setFooter({ text: this.t(msg, "responses._common.sessionEnded") });
|
||||
closedEmbed.setTitle(this.t(msg, "responses.player.inactiveTitle"));
|
||||
|
||||
await message.edit({
|
||||
embeds: [closedEmbed],
|
||||
@@ -301,7 +302,7 @@ export async function run(msg) {
|
||||
if (player.paused) {
|
||||
reply = player.resume();
|
||||
} else if (!player.queue.getCurrent() && !player.queue.isEmpty()) {
|
||||
player.playNext();
|
||||
player.playNext().catch(() => {});
|
||||
reply = this.t(msg, "responses.player.startingPlayback");
|
||||
} else {
|
||||
reply = this.t(msg, "responses.player.alreadyPlaying");
|
||||
@@ -360,7 +361,7 @@ export async function run(msg) {
|
||||
shouldUpdate = true;
|
||||
try {
|
||||
const { run: runFilter } = await import("./filter.mjs");
|
||||
runFilter.call(this, msg);
|
||||
await runFilter.call(this, msg);
|
||||
} catch (err) {
|
||||
reply = this.t(msg, "responses.player.filterError", { error: Utils.truncate(err.message, 50) });
|
||||
}
|
||||
@@ -499,4 +500,4 @@ export async function run(msg) {
|
||||
|
||||
resetTimeout();
|
||||
resetEmojiTimer();
|
||||
}
|
||||
}
|
||||
+19
-11
@@ -1,17 +1,13 @@
|
||||
/**
|
||||
* @file playnext.mjs — Add a song to the top of the queue (play next)
|
||||
* @module commands.playnext
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { PROVIDER_CHOICES } from "../src/constants/providers.mjs";
|
||||
import { PROVIDER_CHOICES, parseInlineProvider } from "../src/constants/providers.mjs";
|
||||
|
||||
function parseInlineProvider(raw) {
|
||||
const match = raw.match(/^([a-z]+):\s*(.+)$/i);
|
||||
if (!match) return { provider: null, query: raw.trim() };
|
||||
const maybeProvider = match[1].toLowerCase();
|
||||
if (PROVIDER_CHOICES.includes(maybeProvider)) {
|
||||
return { provider: maybeProvider, query: match[2].trim() };
|
||||
}
|
||||
return { provider: null, query: raw.trim() };
|
||||
}
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("playnext")
|
||||
@@ -37,6 +33,12 @@ export const command = new CommandBuilder()
|
||||
, true)
|
||||
.addAlias("pn");
|
||||
|
||||
/**
|
||||
* Execute the playnext command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @param {Map<string, {value: *}>>} data - Slash-command options map
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(message, data) {
|
||||
const p = await this.getPlayer(message, true, true, true);
|
||||
if (!p) return;
|
||||
@@ -50,7 +52,13 @@ export async function run(message, data) {
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(this.t(message, "responses.playnext.searching"))
|
||||
;
|
||||
const statusMsg = await message.reply({ embeds: [searchEmbed] });
|
||||
|
||||
let statusMsg;
|
||||
try {
|
||||
statusMsg = await message.reply({ embeds: [searchEmbed] });
|
||||
} catch (_e) {
|
||||
return;
|
||||
}
|
||||
|
||||
const messages = p.playFirst(query, provider);
|
||||
messages.on("message", d => {
|
||||
|
||||
+18
-16
@@ -1,17 +1,13 @@
|
||||
/**
|
||||
* @file radio.mjs — Play a radio stream or search for radio stations
|
||||
* @module commands.radio
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { NUMBER_EMOJIS, CANCEL_EMOJI, PREV_EMOJI, NEXT_EMOJI } from "../src/constants/UI.mjs";
|
||||
|
||||
const NUMBER_EMOJIS = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣","8️⃣","9️⃣"];
|
||||
const CANCEL_EMOJI = "❌";
|
||||
const PREV_EMOJI = "⬅️";
|
||||
const NEXT_EMOJI = "➡️";
|
||||
|
||||
function mkEmbed(desc, title) {
|
||||
const b = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
|
||||
if (title) b.setTitle(title);
|
||||
return { embeds: [b] };
|
||||
}
|
||||
|
||||
export const command = function() {
|
||||
if (!this.config.radio?.length) return null;
|
||||
@@ -27,9 +23,15 @@ 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
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(msg, data) {
|
||||
const radios = this.config.radio;
|
||||
if (!radios?.length) return msg.reply(mkEmbed(this.t(msg, "responses.radio.noStations")));
|
||||
if (!radios?.length) return msg.reply(this.t(msg, "responses.radio.noStations"));
|
||||
|
||||
const input = (data.get("station")?.value ?? "").trim().toLowerCase();
|
||||
|
||||
@@ -49,7 +51,7 @@ export async function run(msg, data) {
|
||||
});
|
||||
desc += `⬅️ Previous ➡️ Next ❌ Cancel`;
|
||||
|
||||
return { payload: mkEmbed(desc), pickable };
|
||||
return { payload: { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] }, pickable };
|
||||
};
|
||||
|
||||
let { payload, pickable } = buildPage();
|
||||
@@ -67,7 +69,7 @@ export async function run(msg, data) {
|
||||
await rawMsg.removeAllReactions();
|
||||
} catch (_) {
|
||||
for (const emoji of baseEmojis) {
|
||||
try { await rawMsg.removeReaction(emoji); } catch (_) {}
|
||||
try { await rawMsg.removeReaction(emoji); } catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -77,7 +79,7 @@ export async function run(msg, data) {
|
||||
settled = true;
|
||||
unobserve();
|
||||
clearReactions().catch(() => {});
|
||||
listMsg.edit(mkEmbed(this.t(msg, "responses.radio.timedOut"))).catch(() => {});
|
||||
listMsg.edit(this.t(msg, "responses.radio.timedOut")).catch(() => {});
|
||||
}, 60_000);
|
||||
|
||||
const normalize = (s) => s.replace(/\uFE0F/g, "");
|
||||
@@ -91,7 +93,7 @@ export async function run(msg, data) {
|
||||
clearTimeout(timeout);
|
||||
unobserve();
|
||||
await clearReactions();
|
||||
listMsg.edit(mkEmbed(this.t(msg, "responses.radio.cancelled"))).catch(() => {});
|
||||
listMsg.edit(this.t(msg, "responses.radio.cancelled")).catch(() => {});
|
||||
return;
|
||||
}
|
||||
if (emoji === normalize(NEXT_EMOJI)) page = (page + 1) % totalPages;
|
||||
@@ -120,7 +122,7 @@ export async function run(msg, data) {
|
||||
const radio = radios.find(r => r.name.toLowerCase() === input);
|
||||
if (!radio) {
|
||||
const names = radios.map(r => `\`${r.name}\``).join(", ");
|
||||
return msg.reply(mkEmbed(this.t(msg, "responses.radio.unknownStation", { station: input, stations: names })));
|
||||
return msg.reply(this.t(msg, "responses.radio.unknownStation", { station: input, stations: names }));
|
||||
}
|
||||
return playStation(this, msg, radio);
|
||||
}
|
||||
|
||||
+19
-11
@@ -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 })
|
||||
));
|
||||
);
|
||||
}
|
||||
+13
-2
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file remove.mjs — Remove a specific song from the queue by position
|
||||
* @module commands.remove
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
@@ -9,11 +14,17 @@ export const command = new CommandBuilder()
|
||||
.setDescription("The position of the song in the queue. You can view the indices with the 'list' command", "options.remove.index")
|
||||
.setRequired(true));
|
||||
|
||||
/**
|
||||
* Execute the remove command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @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.");
|
||||
if (index == null || index < 1) return message.replyEmbed("Queue position must be 1 or greater.").catch(() => {});
|
||||
const res = p.remove(index - 1);
|
||||
message.replyEmbed(res);
|
||||
message.replyEmbed(res).catch(() => {});
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file resume.mjs — Resume paused playback
|
||||
* @module commands.resume
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -7,6 +12,11 @@ export const command = new CommandBuilder()
|
||||
.setDescription("Resume the playback in your voice channel", "commands.resume")
|
||||
.setCategory("music");
|
||||
|
||||
/**
|
||||
* Execute the resume 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, true, false);
|
||||
if (!p) return;
|
||||
@@ -15,5 +25,5 @@ export async function run(message) {
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(res)
|
||||
;
|
||||
message.reply({ embeds: [embed] });
|
||||
message.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+14
-14
@@ -1,19 +1,13 @@
|
||||
/**
|
||||
* @file search.mjs — Search for songs with interactive selection menu
|
||||
* @module commands.search
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { Message, getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { PROVIDER_CHOICES, PROVIDER_NAMES } from "../src/constants/providers.mjs";
|
||||
|
||||
const NUMBER_EMOJIS = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣","8️⃣","9️⃣"];
|
||||
const CANCEL_EMOJI = "❌";
|
||||
|
||||
function parseInlineProvider(raw) {
|
||||
const match = raw.match(/^([a-z]+):\s*(.+)$/i);
|
||||
if (!match) return { provider: null, query: raw.trim() };
|
||||
const maybeProvider = match[1].toLowerCase();
|
||||
if (PROVIDER_CHOICES.includes(maybeProvider))
|
||||
return { provider: maybeProvider, query: match[2].trim() };
|
||||
return { provider: null, query: raw.trim() };
|
||||
}
|
||||
import { PROVIDER_CHOICES, PROVIDER_NAMES, parseInlineProvider } from "../src/constants/providers.mjs";
|
||||
import { NUMBER_EMOJIS, CANCEL_EMOJI } from "../src/constants/UI.mjs";
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("search")
|
||||
@@ -41,6 +35,12 @@ export const command = new CommandBuilder()
|
||||
.setRequired(true)
|
||||
);
|
||||
|
||||
/**
|
||||
* Execute the search 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 p = await this.getPlayer(msg, true, true, true);
|
||||
if (!p) return;
|
||||
@@ -115,7 +115,7 @@ export async function run(msg, data) {
|
||||
const clearReactions = async () => {
|
||||
try {
|
||||
await rawMsg.removeAllReactions();
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
};
|
||||
|
||||
const wrapped = new Message(rawMsg, this.messages);
|
||||
|
||||
+23
-49
@@ -1,6 +1,13 @@
|
||||
/**
|
||||
* @file seek.mjs — Seek to a specific position in the current track
|
||||
* @module commands.seek
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { Utils } from "../src/Utils.mjs";
|
||||
import { ERROR_COLOR } from "../src/constants/UI.mjs";
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("seek")
|
||||
@@ -12,6 +19,12 @@ export const command = new CommandBuilder()
|
||||
.setRequired(true)
|
||||
);
|
||||
|
||||
/**
|
||||
* Execute the seek 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 positionInput = data.get("position")?.value;
|
||||
|
||||
@@ -19,73 +32,34 @@ export async function run(msg, data) {
|
||||
if (!p) return;
|
||||
|
||||
if (!p.queue?.getCurrent()) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.nothingPlaying"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.nothingPlaying"))] });
|
||||
}
|
||||
|
||||
if (p._paused) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.paused"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.paused"))] });
|
||||
}
|
||||
|
||||
let seekMs = parseSeekPosition(positionInput);
|
||||
if (seekMs === null || seekMs < 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.invalidFormat"))] });
|
||||
let seekMs = Utils.parseDuration(positionInput);
|
||||
if (!seekMs || seekMs < 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.invalidFormat"))] });
|
||||
}
|
||||
|
||||
const trackDuration = p._getTrackDurationMs(p.queue.getCurrent());
|
||||
|
||||
if (trackDuration > 0 && seekMs >= trackDuration) {
|
||||
const maxStr = formatDuration(trackDuration);
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.exceedsDuration", { duration: maxStr }))] });
|
||||
const maxStr = Utils.prettifyMS(trackDuration);
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.exceedsDuration", { duration: maxStr }))] });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await p.seekToPosition(seekMs);
|
||||
if (result) {
|
||||
const seekStr = formatDuration(seekMs);
|
||||
const totalStr = trackDuration > 0 ? formatDuration(trackDuration) : "∞";
|
||||
const seekStr = Utils.prettifyMS(seekMs);
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.seek.seeked", { position: seekStr }))] });
|
||||
} else {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.notSupported"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.notSupported"))] });
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.seek.failed", { error: err.message }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.failed", { error: err.message }))] });
|
||||
}
|
||||
}
|
||||
|
||||
function parseSeekPosition(str) {
|
||||
if (!str || typeof str !== "string") return null;
|
||||
str = str.trim();
|
||||
|
||||
if (/^\d+$/.test(str)) {
|
||||
return parseInt(str, 10) * 1000;
|
||||
}
|
||||
|
||||
const parts = str.split(":").map(Number);
|
||||
if (parts.some(isNaN)) return null;
|
||||
|
||||
if (parts.length === 2) {
|
||||
const [minutes, seconds] = parts;
|
||||
if (seconds >= 60) return null;
|
||||
return (minutes * 60 + seconds) * 1000;
|
||||
}
|
||||
|
||||
if (parts.length === 3) {
|
||||
const [hours, minutes, seconds] = parts;
|
||||
if (minutes >= 60 || seconds >= 60) return null;
|
||||
return (hours * 3600 + minutes * 60 + seconds) * 1000;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatDuration(ms) {
|
||||
const totalSeconds = Math.floor(ms / 1000);
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
|
||||
if (hours > 0) {
|
||||
return `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
|
||||
}
|
||||
return `${minutes}:${String(seconds).padStart(2, "0")}`;
|
||||
}
|
||||
+13
-3
@@ -1,6 +1,12 @@
|
||||
/**
|
||||
* @file servers.mjs — List servers the bot is currently in (owner-only)
|
||||
* @module commands.servers
|
||||
*/
|
||||
|
||||
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";
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("servers")
|
||||
@@ -8,8 +14,12 @@ export const command = new CommandBuilder()
|
||||
.setRequirement(r => r.setOwnerOnly(true))
|
||||
.setCategory("util");
|
||||
|
||||
const EMOJI_REMOVE_TIMEOUT = 60000;
|
||||
|
||||
/**
|
||||
* Execute the servers command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(msg) {
|
||||
const guilds = [...this.client.guilds.values()];
|
||||
|
||||
@@ -86,7 +96,7 @@ export async function run(msg) {
|
||||
for (const emoji of navEmojis) {
|
||||
try {
|
||||
await replyMsg.message.removeReaction(emoji);
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -113,4 +123,4 @@ export async function run(msg) {
|
||||
});
|
||||
|
||||
resetTimer();
|
||||
}
|
||||
}
|
||||
+24
-27
@@ -1,6 +1,11 @@
|
||||
/**
|
||||
* @file settings.mjs — Configure server settings — prefix, volume, 24/7 mode, DJ role, locale, and more
|
||||
* @module commands.settings
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { getGlobalColor, cleanId, getMessageGuildId } from "../src/MessageHandler.mjs";
|
||||
import runnables from "../settings/runnables.mjs";
|
||||
|
||||
function embed(desc, opts = {}) {
|
||||
@@ -50,10 +55,6 @@ const VOLUME_MIN = 1;
|
||||
const VOLUME_MAX = 200;
|
||||
const MAX_247_CHANNELS = 10;
|
||||
|
||||
/** Extract clean numeric channel ID from any format */
|
||||
function cleanId(raw) {
|
||||
return String(raw).replace(/\D/g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a value looks like a real Fluxer ID.
|
||||
@@ -62,7 +63,7 @@ function cleanId(raw) {
|
||||
* (which would be garbage like "3", "42", "move", etc.).
|
||||
*/
|
||||
function isValidFluxerId(id) {
|
||||
const cleaned = String(id).replace(/\D/g, "");
|
||||
const cleaned = cleanId(id);
|
||||
return cleaned.length >= 15 && cleaned.length <= 22;
|
||||
}
|
||||
|
||||
@@ -81,16 +82,6 @@ function displayValue(key, value) {
|
||||
return `\`${value}\``;
|
||||
}
|
||||
|
||||
/** Resolve guild ID from a message context */
|
||||
function getGuildId(message) {
|
||||
return message.message?.guildId
|
||||
?? message.message?.guild?.id
|
||||
?? message.channel?.guildId
|
||||
?? message.channel?.guild?.id
|
||||
?? message.channel?.server_id
|
||||
?? message.channel?.serverId
|
||||
?? null;
|
||||
}
|
||||
|
||||
/** Resolve guild name from a message context */
|
||||
function getGuildName(message) {
|
||||
@@ -192,7 +183,7 @@ function resolveChannelName(client, channelId) {
|
||||
try {
|
||||
const ch = client?.channels?.get?.(channelId);
|
||||
if (ch?.name) return ch.name;
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -406,7 +397,7 @@ function prettifySettingLabel(key, t, guildId) {
|
||||
|
||||
async function handle247(ctx, message, value) {
|
||||
const set = ctx.getSettings(message);
|
||||
const guildId = getGuildId(message);
|
||||
const guildId = getMessageGuildId(message);
|
||||
const mode = value.toLowerCase().trim();
|
||||
|
||||
const resolved = mode === "true" ? "auto" : mode === "false" ? "off" : mode;
|
||||
@@ -420,7 +411,7 @@ async function handle247(ctx, message, value) {
|
||||
if (resolved === "off") {
|
||||
if (!guildId) return message.reply(embed(ctx.t(message, "responses.settings.noServer")));
|
||||
|
||||
const channelId = ctx.players.checkVoiceChannels(message);
|
||||
const { channelId } = await ctx.players.checkVoiceChannels(message);
|
||||
const channels = get247Channels(set);
|
||||
|
||||
if (channelId) {
|
||||
@@ -474,7 +465,7 @@ async function handle247(ctx, message, value) {
|
||||
|
||||
if (!guildId) return message.reply(embed(ctx.t(message, "responses.settings.noServer")));
|
||||
|
||||
const userChannelId = ctx.players.checkVoiceChannels(message);
|
||||
const { channelId: userChannelId } = await ctx.players.checkVoiceChannels(message);
|
||||
if (!userChannelId) {
|
||||
return message.reply(embed(
|
||||
ctx.t(message, "responses.settings.noVoice247", { mode: resolved, prefix: ctx.handler.getPrefix(guildId) })
|
||||
@@ -554,7 +545,7 @@ async function applySet(ctx, message, set, key, rawValue) {
|
||||
});
|
||||
}
|
||||
set.set(key, rawValue);
|
||||
const guildId = getGuildId(message);
|
||||
const guildId = getMessageGuildId(message);
|
||||
if (guildId) ctx.locale.invalidateCache(guildId);
|
||||
return null;
|
||||
}
|
||||
@@ -583,7 +574,7 @@ async function handleShortcut(ctx, message, settingKey, valueTokens) {
|
||||
if (valueTokens.length === 0) {
|
||||
if (settingKey === "stay_247") {
|
||||
const t247 = ctx.locale?.translate?.bind(ctx.locale);
|
||||
return message.reply(build247StatusPanel(set, ctx, message, t247, getGuildId(message)));
|
||||
return message.reply(build247StatusPanel(set, ctx, message, t247, getMessageGuildId(message)));
|
||||
}
|
||||
const val = set.get(settingKey);
|
||||
return message.reply(embed(`\`${settingKey}\` → ${displayValue(settingKey, val)}`));
|
||||
@@ -695,6 +686,12 @@ 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
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(message, data) {
|
||||
const set = this.getSettings(message);
|
||||
const cmd = data.commandId || "getSettings";
|
||||
@@ -744,11 +741,11 @@ export async function run(message, data) {
|
||||
if (settingKey) {
|
||||
if (settingKey === "stay_247") {
|
||||
const t247 = this.locale?.translate?.bind(this.locale);
|
||||
return message.reply(build247StatusPanel(set, this, message, t247, getGuildId(message)));
|
||||
return message.reply(build247StatusPanel(set, this, message, t247, getMessageGuildId(message)));
|
||||
}
|
||||
const val = set.get(settingKey);
|
||||
const description = this.settingsMgr.descriptions?.[settingKey];
|
||||
const prefix = ctx.handler.getPrefix(guildId);
|
||||
const prefix = this.handler.getPrefix(guildId);
|
||||
const resolvedDesc = description ? description.replace(/\$prefix/gi, prefix) : null;
|
||||
let reply = `**${prettifySettingLabel(settingKey)}**\nValue: ${displayValue(settingKey, val)}`;
|
||||
if (resolvedDesc) reply += `\n\n*${resolvedDesc}*`;
|
||||
@@ -766,7 +763,7 @@ export async function run(message, data) {
|
||||
.filter(([k]) => k !== "stay_247_mode")
|
||||
.map(([k]) => {
|
||||
if (k === "stay_247") {
|
||||
return `• **24/7 mode** — ${format247Status(set, this.locale?.translate?.bind(this.locale), getGuildId(message))}`;
|
||||
return `• **24/7 mode** — ${format247Status(set, this.locale?.translate?.bind(this.locale), getMessageGuildId(message))}`;
|
||||
}
|
||||
return `• **${prettifySettingLabel(k)}** — ${displayValue(k, d[k])}`;
|
||||
});
|
||||
@@ -784,7 +781,7 @@ export async function run(message, data) {
|
||||
}
|
||||
set.reset(settingKey);
|
||||
if (settingKey === "locale") {
|
||||
const guildId = getGuildId(message);
|
||||
const guildId = getMessageGuildId(message);
|
||||
if (guildId) this.locale.invalidateCache(guildId);
|
||||
}
|
||||
const def = set.get(settingKey);
|
||||
@@ -827,7 +824,7 @@ export async function run(message, data) {
|
||||
return message.reply(embed(
|
||||
`**⚙️ Setting: \`${settingKey}\`**\n\n` +
|
||||
`${description}${extra}\n\n` +
|
||||
`**Current value:** ${settingKey === "stay_247" ? format247Status(set, this.locale?.translate?.bind(this.locale), getGuildId(message)) : displayValue(settingKey, currentVal)}\n` +
|
||||
`**Current value:** ${settingKey === "stay_247" ? format247Status(set, this.locale?.translate?.bind(this.locale), getMessageGuildId(message)) : displayValue(settingKey, currentVal)}\n` +
|
||||
`**Default:** ${displayValue(settingKey, defaultVal)}`,
|
||||
{ title: `⚙️ ${settingKey}` }
|
||||
));
|
||||
|
||||
+11
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file shuffle.mjs — Shuffle the current queue
|
||||
* @module commands.shuffle
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -7,6 +12,11 @@ export const command = new CommandBuilder()
|
||||
.setDescription("Re-orders the queue randomly.", "commands.shuffle")
|
||||
.setCategory("music");
|
||||
|
||||
/**
|
||||
* Execute the shuffle 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, true, false);
|
||||
if (!p) return;
|
||||
@@ -15,5 +25,5 @@ export async function run(message) {
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(res)
|
||||
;
|
||||
message.reply({ embeds: [embed] });
|
||||
message.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file skip.mjs — Skip the currently playing song
|
||||
* @module commands.skip
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -8,6 +13,11 @@ export const command = new CommandBuilder()
|
||||
.addAliases("s")
|
||||
.setCategory("music");
|
||||
|
||||
/**
|
||||
* Execute the skip 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);
|
||||
if (!p) return;
|
||||
@@ -30,5 +40,5 @@ export async function run(message) {
|
||||
.setColor(getGlobalColor())
|
||||
.setDescription(desc)
|
||||
;
|
||||
message.reply({ embeds: [embed] });
|
||||
message.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+12
-1
@@ -1,7 +1,13 @@
|
||||
/**
|
||||
* @file stats.mjs — Display bot statistics — uptime, servers, users, and memory usage
|
||||
* @module commands.stats
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { Utils } from "../src/Utils.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("stats")
|
||||
@@ -162,6 +168,11 @@ function buildEmbed(t, msg, { guildCount, userCount, playerCount, scrobbleCount,
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the stats command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(message) {
|
||||
const lastfm = this.lastfm;
|
||||
const lastfmEnabled = lastfm?.enabled ?? false;
|
||||
@@ -199,5 +210,5 @@ export async function run(message) {
|
||||
|
||||
await msg.edit({
|
||||
embeds: [buildEmbed((...a) => this.t(...a), message, { ...shared, guildCount, userCount: users, scrobbleCount, linkedUsers, ping, loading: false })]
|
||||
}).catch((err) => console.error("[stats] editEmbed failed:", err));
|
||||
}).catch((err) => logger.error("[stats] editEmbed failed:", err));
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file support.mjs — Show support server invite link
|
||||
* @module commands.support
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -8,6 +13,11 @@ export const command = new CommandBuilder()
|
||||
.addAliases("server")
|
||||
.setCategory("util");
|
||||
|
||||
/**
|
||||
* run function.
|
||||
* @param {{*}} msg
|
||||
* @returns {*}
|
||||
*/
|
||||
export function run(msg) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
@@ -16,5 +26,5 @@ export function run(msg) {
|
||||
this.t(msg, "responses.support.description")
|
||||
)
|
||||
;
|
||||
msg.reply({ embeds: [embed] });
|
||||
msg.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+13
-2
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file test.mjs — Test/debug command for voice channel user detection
|
||||
* @module commands.test
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -7,6 +12,12 @@ export const command = new CommandBuilder()
|
||||
.setDescription("Shows how many people are in each voice channel.")
|
||||
.setRequirement(r => r.setOwnerOnly(true));
|
||||
|
||||
/**
|
||||
* Execute the test 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 guild = msg.channel?.channel?.guild ?? msg.message?.guild;
|
||||
if (!guild) {
|
||||
@@ -56,7 +67,7 @@ export async function run(msg, data) {
|
||||
try {
|
||||
const fetched = await this.client.channels.fetch(channelId);
|
||||
if (fetched?.name) return fetched.name;
|
||||
} catch (_) {}
|
||||
} catch(e) { }
|
||||
return `Unknown (${channelId})`;
|
||||
};
|
||||
|
||||
@@ -73,5 +84,5 @@ export async function run(msg, data) {
|
||||
.setTitle(this.t(msg, "responses.test.title"))
|
||||
.setDescription(desc.trim().slice(0, 4096))
|
||||
;
|
||||
msg.reply({ embeds: [embed] });
|
||||
msg.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file thumbnail.mjs — Get the thumbnail image for the current or specified track
|
||||
* @module commands.thumbnail
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
@@ -8,6 +13,11 @@ export const command = new CommandBuilder()
|
||||
.addAliases("thumb")
|
||||
.setCategory("music");
|
||||
|
||||
/**
|
||||
* Execute the thumbnail command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} msg - The incoming message
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function run(msg) {
|
||||
const p = await this.getPlayer(msg);
|
||||
if (!p) return;
|
||||
@@ -18,5 +28,5 @@ export async function run(msg) {
|
||||
.setDescription(data.msg);
|
||||
if (data.image) embed.setImage(data.image);
|
||||
|
||||
msg.reply({ embeds: [embed] });
|
||||
msg.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+64
-61
@@ -1,7 +1,14 @@
|
||||
/**
|
||||
* @file trackopt.mjs — Manage per-track options — auto-seek start position and end-time timer
|
||||
* @module commands.trackopt
|
||||
*/
|
||||
|
||||
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 { ERROR_COLOR } from "../src/constants/UI.mjs";
|
||||
|
||||
const DEFAULT_ALIAS = "default";
|
||||
|
||||
@@ -51,35 +58,6 @@ export const command = new CommandBuilder()
|
||||
)
|
||||
.addAlias("to");
|
||||
|
||||
function parseTimeInput(str) {
|
||||
if (!str || typeof str !== "string") return null;
|
||||
str = str.trim();
|
||||
if (/^\d+$/.test(str)) return parseInt(str, 10) * 1000;
|
||||
const parts = str.split(":").map(Number);
|
||||
if (parts.some(isNaN)) return null;
|
||||
if (parts.length === 2) {
|
||||
const [minutes, seconds] = parts;
|
||||
if (seconds >= 60) return null;
|
||||
return (minutes * 60 + seconds) * 1000;
|
||||
}
|
||||
if (parts.length === 3) {
|
||||
const [hours, minutes, seconds] = parts;
|
||||
if (minutes >= 60 || seconds >= 60) return null;
|
||||
return (hours * 3600 + minutes * 60 + seconds) * 1000;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatMs(ms) {
|
||||
if (ms == null || ms < 0) return "0:00";
|
||||
const totalSeconds = Math.floor(ms / 1000);
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
if (hours > 0) return `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
|
||||
return `${minutes}:${String(seconds).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function extractAlias(parts) {
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
if (parts[i].toLowerCase().startsWith("alias:")) {
|
||||
@@ -91,10 +69,16 @@ function extractAlias(parts) {
|
||||
return DEFAULT_ALIAS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the trackopt 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 trackOpts = this.trackOptions;
|
||||
if (!trackOpts) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.notAvailable"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.notAvailable"))] });
|
||||
}
|
||||
|
||||
const subCommand = data.command.name || data.commandId || "get";
|
||||
@@ -104,12 +88,12 @@ export async function run(msg, data) {
|
||||
|
||||
const current = p.queue?.getCurrent();
|
||||
if (!current && subCommand !== "list") {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.nothingPlaying"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.nothingPlaying"))] });
|
||||
}
|
||||
|
||||
const userId = msg.message?.author?.id ?? msg.author?.id;
|
||||
if (!userId) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses._common.noVoiceChannel"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses._common.noVoiceChannel"))] });
|
||||
}
|
||||
|
||||
const prefix = this.handler.getPrefix(msg.message?.guildId);
|
||||
@@ -117,49 +101,57 @@ export async function run(msg, data) {
|
||||
if (subCommand === "set") {
|
||||
const timesRaw = data.get("times")?.value;
|
||||
if (!timesRaw) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
}
|
||||
|
||||
const parts = timesRaw.trim().split(/\s+/);
|
||||
const aliasRaw = extractAlias(parts);
|
||||
|
||||
const startMs = parseTimeInput(parts[0]);
|
||||
if (startMs === null || startMs < 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
const startMs = Utils.parseDuration(parts[0]);
|
||||
if (!startMs || startMs < 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
}
|
||||
|
||||
let endMs = 0;
|
||||
if (parts.length > 1) {
|
||||
endMs = parseTimeInput(parts[1]);
|
||||
if (endMs === null || endMs <= 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
endMs = Utils.parseDuration(parts[1]);
|
||||
if (!endMs || endMs <= 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.invalidFormat"))] });
|
||||
}
|
||||
if (endMs <= startMs) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidEndAfterStart"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.invalidEndAfterStart"))] });
|
||||
}
|
||||
}
|
||||
|
||||
const trackDuration = p._getTrackDurationMs(current);
|
||||
if (trackDuration > 0) {
|
||||
if (startMs >= trackDuration) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.startExceedsDuration", { duration: formatMs(trackDuration) }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.startExceedsDuration", { duration: Utils.prettifyMS(trackDuration) }))] });
|
||||
}
|
||||
if (endMs > 0 && endMs > trackDuration) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.endExceedsDuration", { duration: formatMs(trackDuration) }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.endExceedsDuration", { duration: Utils.prettifyMS(trackDuration) }))] });
|
||||
}
|
||||
}
|
||||
|
||||
const result = await trackOpts.set(userId, current, startMs, endMs, aliasRaw);
|
||||
if (!result) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.saveFailed"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.saveFailed"))] });
|
||||
}
|
||||
|
||||
const endLabel = endMs > 0 ? formatMs(endMs) : "full track";
|
||||
if (result.alias === DEFAULT_ALIAS && p.connection && !p._paused && startMs > 0) {
|
||||
try {
|
||||
await p.applyTrackOption({ startMs, endMs, alias: result.alias, userId });
|
||||
} catch (applyErr) {
|
||||
logger.warn("[trackopt] Auto-apply after set failed:", applyErr.message);
|
||||
}
|
||||
}
|
||||
|
||||
const endLabel = endMs > 0 ? Utils.prettifyMS(endMs) : "full track";
|
||||
let desc;
|
||||
if (result.alias === DEFAULT_ALIAS) {
|
||||
desc = this.t(msg, "responses.trackopt.saved", { title: current.title, aliasLabel: "", start: formatMs(startMs), end: endLabel });
|
||||
desc = this.t(msg, "responses.trackopt.saved", { title: current.title, aliasLabel: "", start: Utils.prettifyMS(startMs), end: endLabel });
|
||||
} else {
|
||||
desc = this.t(msg, "responses.trackopt.savedAlias", { title: current.title, alias: result.alias, start: formatMs(startMs), end: endLabel, prefix });
|
||||
desc = this.t(msg, "responses.trackopt.savedAlias", { title: current.title, alias: result.alias, start: Utils.prettifyMS(startMs), end: endLabel, prefix });
|
||||
}
|
||||
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] });
|
||||
@@ -168,15 +160,15 @@ export async function run(msg, data) {
|
||||
if (subCommand === "get") {
|
||||
const rows = await trackOpts.getAllForTrack(userId, current);
|
||||
if (!rows || rows.length === 0) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.notSet", { title: current.title }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.notSet", { title: current.title }))] });
|
||||
}
|
||||
|
||||
let desc = this.t(msg, "responses.trackopt.current", { title: current.title, count: rows.length }) + "\n\n";
|
||||
for (const row of rows) {
|
||||
const aliasLabel = row.alias === DEFAULT_ALIAS ? "default" : row.alias;
|
||||
const endStr = row.end_ms > 0 ? formatMs(row.end_ms) : "end";
|
||||
const endStr = row.end_ms > 0 ? Utils.prettifyMS(row.end_ms) : "end";
|
||||
const autoTag = row.alias === DEFAULT_ALIAS ? " ← auto" : "";
|
||||
desc += this.t(msg, "responses.trackopt.currentEntry", { alias: aliasLabel, start: formatMs(row.start_ms), end: endStr, autoTag }) + "\n";
|
||||
desc += this.t(msg, "responses.trackopt.currentEntry", { alias: aliasLabel, start: Utils.prettifyMS(row.start_ms), end: endStr, autoTag }) + "\n";
|
||||
}
|
||||
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] });
|
||||
@@ -185,12 +177,12 @@ export async function run(msg, data) {
|
||||
if (subCommand === "play") {
|
||||
const aliasRaw = data.get("alias")?.value;
|
||||
if (!aliasRaw) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.provideAlias", { prefix }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.provideAlias", { prefix }))] });
|
||||
}
|
||||
|
||||
const safeAlias = aliasRaw.toLowerCase().replace(/[^a-zA-Z0-9_-]/g, "").slice(0, 32);
|
||||
if (!safeAlias) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.invalidAlias"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.invalidAlias"))] });
|
||||
}
|
||||
|
||||
const result = await trackOpts.get(userId, current, safeAlias);
|
||||
@@ -198,26 +190,26 @@ export async function run(msg, data) {
|
||||
const allAliases = await trackOpts.getAllForTrack(userId, current);
|
||||
if (allAliases.length > 0) {
|
||||
const names = allAliases.map(r => r.alias === DEFAULT_ALIAS ? "default" : r.alias).join(", ");
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.aliasNotFound", { alias: safeAlias, title: current.title, names }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.aliasNotFound", { alias: safeAlias, title: current.title, names }))] });
|
||||
}
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.notFound", { title: current.title }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.notFound", { title: current.title }))] });
|
||||
}
|
||||
|
||||
if (!p.connection || p._paused) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.mustBePlaying"))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.mustBePlaying"))] });
|
||||
}
|
||||
|
||||
try {
|
||||
const applied = await p.applyTrackOption(result);
|
||||
if (!applied) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.applyFailed", { error: "Unknown error" }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.applyFailed", { error: "Unknown error" }))] });
|
||||
}
|
||||
|
||||
const aliasLabel = safeAlias === DEFAULT_ALIAS ? "default" : safeAlias;
|
||||
const endStr = result.endMs > 0 ? formatMs(result.endMs) : "end";
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.trackopt.applied", { alias: aliasLabel, start: formatMs(result.startMs), end: endStr }))] });
|
||||
const endStr = result.endMs > 0 ? Utils.prettifyMS(result.endMs) : "end";
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.trackopt.applied", { alias: aliasLabel, start: Utils.prettifyMS(result.startMs), end: endStr }))] });
|
||||
} catch (e) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.applyFailed", { error: e.message }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.applyFailed", { error: e.message }))] });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +217,18 @@ export async function run(msg, data) {
|
||||
const aliasRaw = data.get("alias")?.value;
|
||||
const removed = await trackOpts.remove(userId, current, aliasRaw || null);
|
||||
if (!removed) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription(this.t(msg, "responses.trackopt.notFound", { title: current.title }))] });
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.trackopt.notFound", { title: current.title }))] });
|
||||
}
|
||||
if (p._activeTrackOpt) {
|
||||
const removeDefault = !aliasRaw || aliasRaw.toLowerCase() === DEFAULT_ALIAS;
|
||||
const activeIsDefault = p._activeTrackOpt.alias === DEFAULT_ALIAS;
|
||||
if (removeDefault && activeIsDefault) {
|
||||
p._activeTrackOpt = null;
|
||||
p._clearTrackEndTimer();
|
||||
} else if (aliasRaw && p._activeTrackOpt.alias === aliasRaw.toLowerCase()) {
|
||||
p._activeTrackOpt = null;
|
||||
p._clearTrackEndTimer();
|
||||
}
|
||||
}
|
||||
if (aliasRaw) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.trackopt.removedAlias", { alias: aliasRaw, title: current.title }))] });
|
||||
@@ -244,14 +247,14 @@ export async function run(msg, data) {
|
||||
for (const row of rows) {
|
||||
const title = row.track_title || row.track_identifier;
|
||||
const aliasLabel = row.alias === DEFAULT_ALIAS ? "default" : row.alias;
|
||||
const endStr = row.end_ms > 0 ? formatMs(row.end_ms) : "end";
|
||||
const endStr = row.end_ms > 0 ? Utils.prettifyMS(row.end_ms) : "end";
|
||||
if (title !== lastTrack) {
|
||||
if (lastTrack) desc += "\n";
|
||||
desc += `🎵 **${title}**\n`;
|
||||
lastTrack = title;
|
||||
}
|
||||
const autoTag = row.alias === DEFAULT_ALIAS ? " ← auto" : "";
|
||||
desc += ` • ${aliasLabel}: ${formatMs(row.start_ms)} → ${endStr}${autoTag}\n`;
|
||||
desc += ` • ${aliasLabel}: ${Utils.prettifyMS(row.start_ms)} → ${endStr}${autoTag}\n`;
|
||||
}
|
||||
desc += "\n" + this.t(msg, "responses.trackopt.listHint", { prefix });
|
||||
|
||||
|
||||
+13
-2
@@ -1,8 +1,13 @@
|
||||
/**
|
||||
* @file volume.mjs — Set or view the playback volume
|
||||
* @module commands.volume
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { MAX_VOLUME } from "../src/constants/UI.mjs";
|
||||
|
||||
const MAX_VOLUME = 200;
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("volume")
|
||||
@@ -15,6 +20,12 @@ export const command = new CommandBuilder()
|
||||
)
|
||||
.addAliases("v", "vol");
|
||||
|
||||
/**
|
||||
* Execute the volume command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @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;
|
||||
@@ -37,5 +48,5 @@ export async function run(message, data) {
|
||||
}
|
||||
}
|
||||
|
||||
message.reply({ embeds: [embed] });
|
||||
message.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
/**
|
||||
* @file volumedefault.mjs — Set the default volume for the server
|
||||
* @module commands.volumedefault
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { PermissionFlags } from "@fluxerjs/core";
|
||||
import { MAX_VOLUME } from "../src/constants/UI.mjs";
|
||||
|
||||
const MAX_VOLUME = 200;
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("volumedefault")
|
||||
@@ -16,6 +21,12 @@ export const command = new CommandBuilder()
|
||||
)
|
||||
.addAliases("vd");
|
||||
|
||||
/**
|
||||
* Execute the volumedefault command.
|
||||
* @param {import("../src/MessageHandler.mjs").Message} message - The incoming message
|
||||
* @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;
|
||||
@@ -61,5 +72,5 @@ export async function run(message, data) {
|
||||
}
|
||||
}
|
||||
|
||||
message.reply({ embeds: [embed] });
|
||||
message.reply({ embeds: [embed] }).catch(() => {});
|
||||
}
|
||||
+23
-12
@@ -1,10 +1,15 @@
|
||||
/**
|
||||
* @file vote.mjs — Skip-vote system — start a vote to skip the current track
|
||||
* @module commands.vote
|
||||
*/
|
||||
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
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";
|
||||
|
||||
const EMOJI_REMOVE_TIMEOUT = 60_000;
|
||||
|
||||
export const command = new CommandBuilder()
|
||||
.setName("vote")
|
||||
@@ -37,7 +42,7 @@ export const command = new CommandBuilder()
|
||||
function notConfigured(prefix, t, guildId) {
|
||||
return {
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor("#ff0000")
|
||||
.setColor(ERROR_COLOR)
|
||||
.setDescription(t(guildId, "responses.vote.notConfigured"))]
|
||||
};
|
||||
}
|
||||
@@ -45,7 +50,7 @@ function notConfigured(prefix, t, guildId) {
|
||||
function noResourceId(type, prefix, t, guildId) {
|
||||
return {
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor("#ff0000")
|
||||
.setColor(ERROR_COLOR)
|
||||
.setDescription(t(guildId, "responses.vote.noResourceId", { type, prefix }))]
|
||||
};
|
||||
}
|
||||
@@ -94,6 +99,12 @@ function buildVotersEmbed(voters, total, page, limit, type, resourceId, expired
|
||||
return { embeds: [embed] };
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the vote 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 fluxerlist = this.fluxerlist;
|
||||
const prefix = this.handler.getPrefix(msg.message?.guildId);
|
||||
@@ -157,7 +168,7 @@ export async function run(msg, data) {
|
||||
} catch (err) {
|
||||
return msg.reply({
|
||||
embeds: [new EmbedBuilder()
|
||||
.setColor("#ff0000")
|
||||
.setColor(ERROR_COLOR)
|
||||
.setDescription(this.t(msg, "responses.vote.fetchVotersFailed", { error: err.message }))]
|
||||
});
|
||||
}
|
||||
@@ -179,11 +190,11 @@ export async function run(msg, data) {
|
||||
|
||||
let currentPage = voterData.page;
|
||||
|
||||
const buildPage = (pageIdx, expired = false) => {
|
||||
return buildVotersEmbed(voterData.voters, voterData.total, pageIdx, 20, resolvedType, id, expired, t, guildId);
|
||||
const buildPage = (pageIdx, data, expired = false) => {
|
||||
return buildVotersEmbed(data.voters, data.total, pageIdx, 20, resolvedType, id, expired, t, guildId);
|
||||
};
|
||||
|
||||
const replyMsg = await msg.reply(buildPage(currentPage));
|
||||
const replyMsg = await msg.reply(buildPage(currentPage, voterData));
|
||||
if (!replyMsg?.message) return;
|
||||
|
||||
const navEmojis = ["\u25C0\uFE0F", "\u25B6\uFE0F", "\u274C"];
|
||||
@@ -196,18 +207,18 @@ export async function run(msg, data) {
|
||||
await replyMsg.message.removeAllReactions();
|
||||
} catch {
|
||||
for (const emoji of navEmojis) {
|
||||
try { await replyMsg.message.removeReaction(emoji); } catch {}
|
||||
try { await replyMsg.message.removeReaction(emoji); } catch(e) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let emojiTimeout;
|
||||
let emojiTimeout = null;
|
||||
const resetTimer = () => {
|
||||
clearTimeout(emojiTimeout);
|
||||
emojiTimeout = setTimeout(async () => {
|
||||
unobserve?.();
|
||||
await clearReactions();
|
||||
await replyMsg.edit(buildPage(currentPage, true)).catch(() => {});
|
||||
await replyMsg.edit(buildPage(currentPage, voterData, true)).catch(() => {});
|
||||
}, EMOJI_REMOVE_TIMEOUT);
|
||||
};
|
||||
|
||||
@@ -230,10 +241,10 @@ export async function run(msg, data) {
|
||||
try {
|
||||
voterData = await fluxerlist.getVoters(resolvedType, id, { page: currentPage, limit: 20 });
|
||||
} catch {
|
||||
/* keep previous data */
|
||||
|
||||
}
|
||||
|
||||
await replyMsg.edit(buildPage(currentPage)).catch(() => {});
|
||||
await replyMsg.edit(buildPage(currentPage, voterData)).catch(() => {});
|
||||
});
|
||||
|
||||
resetTimer();
|
||||
|
||||
Reference in new issue
Block a user