feat(ui): modernize bot commands, Last.fm suite, and system embeds

- Modernize audio controls (%volume, %volumedefault, %bassboost, %autoplay, %trackopt, %shuffle, %clear, %list, %pause, %resume)
- Upgrade Last.fm suite (%lastfm play directory, spotlight cards, music podiums, tags, and profile stats)
- Polish system & voice embeds (%vote supporter verification, %servers network directory, %forceleave, and 24/7 watchdog)
- Achieve 100% localization parity across all 6 locales (en, ar-SA, ckb, tr, de-DE, pt-BR) with zero missing keys
This commit is contained in:
NoLogicAlan committed 2026-10-26 02:25:02 +03:00
1 parent 885db461ce
commit e8171dce26
33 files changed
+1529 -440

No files matched your search

+44 -15
View File
@@ -159,23 +159,52 @@ export async function runDiscoveryActions(msg, data, lastfm, prefix, userId, tar
});
}
const lines = trendingData.map((item, i) => {
const num = String(i + 1).padStart(2, " ");
const link = item.url ? `[${item.name}](${item.url})` : item.name;
const artistStr = item.artist ? ` by **${item.artist}**` : "";
const extra = item.listeners ? ` — ${Utils.formatNumber(item.listeners)} ${this.t(msg, "responses.lastfm.listeners")}` : item.playcount ? ` — ${Utils.formatNumber(item.playcount)} ${this.t(msg, "responses.lastfm.plays")}` : "";
return `\`${num}.\` ${link}${artistStr}${extra}`;
});
const isArtists = tokenTextTr === "artists";
trendingTitle = isArtists
? this.t(msg, "responses.lastfm.trendingTitleArtists")
: this.t(msg, "responses.lastfm.trendingTitleTracks");
const desc = lines.join("\n").slice(0, 4096);
const top1 = trendingData[0];
const runners = trendingData.slice(1, 10);
return msg.reply({
embeds: [new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(trendingTitle)
.setDescription(desc)
.setFooter({ text: `💡 Use token option: tracks or artists` })]
});
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.lastfm.trendingAuthor") })
.setTitle(trendingTitle)
.setFooter({ text: this.t(msg, "responses.lastfm.trendingFooterPro", { prefix }) });
if (top1) {
const link = top1.url ? `[${top1.name}](${top1.url})` : top1.name;
const artistStr = top1.artist ? ` by **${top1.artist}**` : "";
const extra = top1.listeners
? ` · **${Utils.formatNumber(top1.listeners)}** ${this.t(msg, "responses.lastfm.listeners")}`
: (top1.playcount ? ` · **${Utils.formatNumber(top1.playcount)}** ${this.t(msg, "responses.lastfm.plays")}` : "");
embed.addFields({
name: `🥇 ${this.t(msg, "responses.lastfm.trendingPodium1")}`,
value: `**${link}**${artistStr}${extra}`,
inline: false
});
}
if (runners.length > 0) {
const MEDALS = ["🥈", "🥉"];
const lines = runners.map((item, i) => {
const badge = i < 2 ? MEDALS[i] : `\`#${i + 2}\``;
const link = item.url ? `[${item.name}](${item.url})` : item.name;
const artistStr = item.artist ? ` · ${item.artist}` : "";
const extra = item.listeners
? ` (${Utils.formatNumber(item.listeners)})`
: (item.playcount ? ` (${Utils.formatNumber(item.playcount)})` : "");
return `${badge} **${link}**${artistStr}${extra}`;
});
embed.addFields({
name: `🔥 ${this.t(msg, "responses.lastfm.trendingRunnersUp")}`,
value: lines.join("\n").slice(0, 1024),
inline: false
});
}
return msg.reply({ embeds: [embed] });
}
case "geo":
+41 -80
View File
@@ -1,8 +1,7 @@
/**
* @module commands/lastfm/help
* @description Fallback help action for the lastfm command (the original
* switch's `default` branch). Extracted verbatim; reached when the action
* matches no known action name.
* @description Fallback help action for the lastfm command.
* Dispatched when the subcommand action matches 'help' or an unknown action.
*/
import { EmbedBuilder } from "@fluxerjs/core";
@@ -17,83 +16,45 @@ import { getGlobalColor } from "../../src/ui/index.mjs";
* @param {string} userId - The invoking user's ID.
* @param {string|null} targetUserId - The targeted user's ID, if any.
* @param {string} action - The resolved action name.
* @returns {Promise<*>} Whatever the original switch returned for this action.
* @returns {Promise<*>} Embed response for Last.fm help.
*/
export async function runLastFmHelp(msg, data, lastfm, prefix, userId, targetUserId, action) {
return msg.reply({
embeds: [new EmbedBuilder()
.setColor(getGlobalColor())
.setDescription([
`🎵 **Last.fm Commands:**`,
``,
`\`${prefix}lastfm link\` — Link your Last.fm account`,
`\`${prefix}lastfm unlink\` — Disconnect your account`,
`\`${prefix}lastfm scrobble\` — Toggle auto-scrobbling`,
`\`${prefix}lastfm np\` — Show your Last.fm now playing`,
`\`${prefix}lastfm profile\` — View your Last.fm profile (or another user's with user option)`,
`\`${prefix}lastfm loved\` — View your loved tracks`,
`\`${prefix}lastfm top\` — View your top tracks (supports period)`,
`\`${prefix}lastfm artists\` — View your top artists (supports period)`,
`\`${prefix}lastfm recent\` — View your recent tracks`,
`\`${prefix}lastfm playlists\` — View your Last.fm playlists`,
`\`${prefix}lastfm leaderboard\` — Scrobble leaderboard`,
`\`${prefix}lastfm love\` — Love the current track`,
`\`${prefix}lastfm unlove\` — Unlove the current track`,
``,
`🔍 **Info Commands:**`,
`\`${prefix}lastfm whoknows [artist]\` — Who in the server listens to an artist`,
`\`${prefix}lastfm whoknowstrack\` — Who knows a specific track`,
`\`${prefix}lastfm whoknowsalbum\` — Who knows a specific album`,
`\`${prefix}lastfm artistinfo\` — Detailed info about an artist`,
`\`${prefix}lastfm albuminfo\` — Detailed info about an album`,
`\`${prefix}lastfm trackinfo\` — Detailed info about a track`,
`\`${prefix}lastfm topalbums\` — View your top albums (supports period)`,
`\`${prefix}lastfm toptags\` — View your top tags/genres`,
`\`${prefix}lastfm tag <name>\` — View info about a specific tag`,
`\`${prefix}lastfm compare @user\` — Compare your taste with another user`,
`\`${prefix}lastfm cover\` — Get album cover art for the current track`,
``,
`🏷️ **Tag Commands:**`,
`\`${prefix}lastfm artisttags\` — Top tags for an artist`,
`\`${prefix}lastfm albumtags\` — Top tags for an album`,
`\`${prefix}lastfm tracktags\` — Top tags for a track`,
`\`${prefix}lastfm tagalbums <tag>\` — Top albums for a tag`,
``,
`👥 **Social Commands:**`,
`\`${prefix}lastfm affinity\` — Find users with similar taste`,
`\`${prefix}lastfm crowns\` — View your artist crowns (#1 listener)`,
`\`${prefix}lastfm friends\` — View your Last.fm friends`,
`\`${prefix}lastfm refreshmembers\` — Refresh server member cache`,
``,
`📊 **Charts & Discovery:**`,
`\`${prefix}lastfm weekly [artists|tracks|albums]\` — Weekly charts`,
`\`${prefix}lastfm trending [tracks|artists]\` — Global trending on Last.fm`,
`\`${prefix}lastfm geo [artists|tracks] <country>\` — Top by country`,
`\`${prefix}lastfm artisttracks\` — Your scrobbles for an artist`,
`\`${prefix}lastfm search <query>\` — Universal search`,
``,
`🎶 **Play from Last.fm:**`,
`\`${prefix}lastfm play loved\` — Play your loved tracks`,
`\`${prefix}lastfm play top\` — Play your top tracks`,
`\`${prefix}lastfm play recent\` — Play your recent tracks`,
`\`${prefix}lastfm play albums\` — Play your top albums`,
`\`${prefix}lastfm play artists\` — Play your top artists' tracks`,
`\`${prefix}lastfm play playlist 1\` — Play a playlist`,
``,
`🎧 **Play with a specific provider (defaults to \`top\`):**`,
`\`${prefix}lastfm play sp\` or \`${prefix}lastfm play sp:top\` — Play top tracks, search on Spotify`,
`\`${prefix}lastfm play td\` or \`${prefix}lastfm play td:top\` — Play top tracks, search on Tidal`,
`\`${prefix}lastfm play dz\` or \`${prefix}lastfm play dz:top\` — Play top tracks, search on Deezer`,
`\`${prefix}lastfm play yt\` or \`${prefix}lastfm play yt:top\` — Play top tracks, search on YouTube`,
``,
`🎧 **Last.fm as resolve provider (all categories):**`,
`\`${prefix}lastfm play lf:loved\` — Play loved tracks, search on Last.fm`,
`\`${prefix}lastfm play lf:top\` — Play top tracks, search on Last.fm`,
`\`${prefix}lastfm play lf:recent\` — Play recent tracks, search on Last.fm`,
`\`${prefix}lastfm play lf:albums\` — Play top albums, search on Last.fm`,
`\`${prefix}lastfm play lf:artists\` — Play top artists, search on Last.fm`,
``,
`💡 Or use inline: \`${prefix}play lastfm:loved\` or \`${prefix}play lastfm:sp\` or \`${prefix}play lastfm:td:top\``,
].join("\n"))]
});
const pfx = prefix || "%";
const accountLines = [
`• \`${pfx}fm link\` · \`${pfx}fm unlink\` · \`${pfx}fm scrobble\` · \`${pfx}fm np\``,
`• \`${pfx}fm profile\` · \`${pfx}fm loved\` · \`${pfx}fm top\` · \`${pfx}fm artists\` · \`${pfx}fm recent\``,
`• \`${pfx}fm love\` · \`${pfx}fm unlove\` · \`${pfx}fm playlists\``
].join("\n");
const discoveryLines = [
`• \`${pfx}fm artistinfo\` · \`${pfx}fm albuminfo\` · \`${pfx}fm trackinfo\` · \`${pfx}fm cover\``,
`• \`${pfx}fm trending\` · \`${pfx}fm weekly\` · \`${pfx}fm tag <name>\` · \`${pfx}fm geo <country>\``,
`• \`${pfx}fm artisttags\` · \`${pfx}fm albumtags\` · \`${pfx}fm tagalbums <tag>\``
].join("\n");
const socialLines = [
`• \`${pfx}whoknows [artist]\` · \`${pfx}fm wkt\` · \`${pfx}fm wka\``,
`• \`${pfx}fm crowns\` · \`${pfx}fm compare @user\` · \`${pfx}fm affinity\` · \`${pfx}fm lb\``,
`• \`${pfx}fm friends\` · \`${pfx}fm refreshmembers\``
].join("\n");
const playbackLines = [
`• \`${pfx}fm play loved\` · \`${pfx}fm play top\` · \`${pfx}fm play albums\` · \`${pfx}fm play artists\``,
`• Cross-provider: \`${pfx}fm play sp:top\` (Spotify) · \`yt:top\` · \`dz:top\` · \`td:top\``
].join("\n");
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.lastfm.helpAuthor") })
.setTitle(this.t(msg, "responses.lastfm.helpTitle"))
.addFields(
{ name: this.t(msg, "responses.lastfm.helpCategoryAccount"), value: accountLines, inline: false },
{ name: this.t(msg, "responses.lastfm.helpCategoryDiscovery"), value: discoveryLines, inline: false },
{ name: this.t(msg, "responses.lastfm.helpCategorySocial"), value: socialLines, inline: false },
{ name: this.t(msg, "responses.lastfm.helpCategoryPlayback"), value: playbackLines, inline: false }
)
.setFooter({ text: this.t(msg, "responses.lastfm.helpFooterPro", { prefix: pfx }) });
return msg.reply({ embeds: [embed] });
}
+104 -36
View File
@@ -196,18 +196,39 @@ export async function runInfoActions(msg, data, lastfm, prefix, userId, targetUs
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.lastfm.albumSpotlightAuthor") })
.setTitle(`💿 ${info.name}`)
.setURL(info.url || undefined)
.setThumbnail(info.image || undefined);
const fields = [];
if (info.artist) {
fields.push({ name: "Artist", value: info.artist, inline: true });
embed.setDescription(`*by* **${info.artist}**`);
}
const fields = [];
if (info.userplaycount != null && user) {
fields.push({ name: "Your Plays", value: Utils.formatNumber(info.userplaycount), inline: true });
fields.push({
name: `🎧 ${this.t(msg, "responses.lastfm.albumFieldYourPlays")}`,
value: `**${Utils.formatNumber(info.userplaycount)}**`,
inline: true,
});
}
if (info.tracks?.length) {
fields.push({
name: `🎼 ${this.t(msg, "responses.lastfm.albumFieldTracks")}`,
value: `**${info.tracks.length}**`,
inline: true,
});
}
if (info.listeners) {
fields.push({
name: `👥 ${this.t(msg, "responses.lastfm.trackFieldListeners")}`,
value: `**${Utils.formatNumber(Number(info.listeners))}**`,
inline: true,
});
}
if (info.tags?.length) {
@@ -215,21 +236,36 @@ export async function runInfoActions(msg, data, lastfm, prefix, userId, targetUs
const tagLower = String(t).toLowerCase().replace(/\s+/g, "+");
return `[${t}](https://www.last.fm/tag/${encodeURIComponent(tagLower)})`;
}).join(" · ");
fields.push({ name: "Tags", value: tagStr, inline: false });
fields.push({
name: `🏷️ ${this.t(msg, "responses.lastfm.albumFieldTags")}`,
value: tagStr,
inline: false,
});
}
if (info.tracks?.length) {
const trackLines = info.tracks.slice(0, 15).map((t, i) => {
const num = String(i + 1).padStart(2, " ");
const trackLines = info.tracks.slice(0, 10).map((t, i) => {
const num = String(i + 1).padStart(2, "0");
const dur = t.duration > 0 ? ` (${formatDuration(t.duration)})` : "";
const link = t.url ? `[${t.name}](${t.url})` : t.name;
return `\`${num}.\` ${link}${dur}`;
});
fields.push({ name: "Tracklist", value: trackLines.join("\n").slice(0, 1024), inline: false });
const extraCount = info.tracks.length > 10 ? `\n*... +${info.tracks.length - 10} more*` : "";
fields.push({
name: `📜 ${this.t(msg, "responses.lastfm.albumFieldTracklist")}`,
value: (trackLines.join("\n") + extraCount).slice(0, 1024),
inline: false,
});
}
embed.addFields(...fields);
embed.setFooter({ text: user ? `Last.fm: ${user.username}` : "Last.fm" });
embed.setFooter({
text: this.t(msg, "responses.lastfm.albumFooterPro", {
prefix,
artist: info.artist || "Artist",
album: info.name,
}),
});
return msg.reply({ embeds: [embed] });
}
@@ -291,6 +327,7 @@ export async function runInfoActions(msg, data, lastfm, prefix, userId, targetUs
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.lastfm.trackSpotlightAuthor") })
.setTitle(`🎵 ${info.name}`)
.setURL(info.url || undefined);
@@ -298,30 +335,55 @@ export async function runInfoActions(msg, data, lastfm, prefix, userId, targetUs
embed.setThumbnail(info.album?.image?.[2]?.["#text"] || info.album?.image?.[1]?.["#text"]);
}
let desc = "";
if (info.artist?.name || info.artist?.["#text"]) {
const aName = String(info.artist?.name ?? info.artist?.["#text"]);
desc += `*by* **${aName}**`;
}
if (info.album?.title) {
desc += ` · *from* **${info.album.title}**`;
}
if (info.wiki?.summary) {
const cleanSummary = info.wiki.summary.replace(/<[^>]*>/g, "").trim();
if (cleanSummary.length > 0) {
const truncated = cleanSummary.length > 200 ? cleanSummary.slice(0, 197) + "..." : cleanSummary;
desc += (desc ? "\n\n" : "") + truncated;
}
}
if (desc) embed.setDescription(desc);
const fields = [];
if (info.artist?.name || info.artist?.["#text"]) {
fields.push({ name: "Artist", value: String(info.artist?.name ?? info.artist?.["#text"] ?? "Unknown"), inline: true });
}
if (info.album?.title) {
fields.push({ name: "Album", value: info.album.title, inline: true });
}
if (info.listeners) {
fields.push({ name: "Listeners", value: Utils.formatNumber(Number(info.listeners)), inline: true });
fields.push({
name: `👥 ${this.t(msg, "responses.lastfm.trackFieldListeners")}`,
value: `**${Utils.formatNumber(Number(info.listeners))}**`,
inline: true,
});
}
if (info.playcount) {
fields.push({ name: "Global Plays", value: Utils.formatNumber(Number(info.playcount)), inline: true });
fields.push({
name: `📈 ${this.t(msg, "responses.lastfm.trackFieldPlays")}`,
value: `**${Utils.formatNumber(Number(info.playcount))}**`,
inline: true,
});
}
if (info.userplaycount) {
fields.push({ name: "Your Plays", value: Utils.formatNumber(Number(info.userplaycount)), inline: true });
fields.push({
name: `🎧 ${this.t(msg, "responses.lastfm.trackFieldUserPlays")}`,
value: `**${Utils.formatNumber(Number(info.userplaycount))}**`,
inline: true,
});
}
const userLoved = info.userloved === "1" || info.userloved === 1 || info.userloved === true;
fields.push({ name: "Loved", value: userLoved ? "❤️ Yes" : "🖤 No", inline: true });
fields.push({
name: `❤️ ${this.t(msg, "responses.lastfm.trackFieldLoved")}`,
value: userLoved ? this.t(msg, "responses.lastfm.lovedStatusYes") : this.t(msg, "responses.lastfm.lovedStatusNo"),
inline: true,
});
if (info.toptags?.tag?.length) {
const tagStr = info.toptags.tag.slice(0, 8).map(t => {
@@ -329,34 +391,40 @@ export async function runInfoActions(msg, data, lastfm, prefix, userId, targetUs
const tagLower = String(tagName).toLowerCase().replace(/\s+/g, "+");
return `[${tagName}](https://www.last.fm/tag/${encodeURIComponent(tagLower)})`;
}).join(" · ");
fields.push({ name: "Tags", value: tagStr, inline: false });
}
embed.addFields(...fields);
if (info.wiki?.summary) {
const cleanSummary = info.wiki.summary.replace(/<[^>]*>/g, "").trim();
if (cleanSummary.length > 0) {
const truncated = cleanSummary.length > 200 ? cleanSummary.slice(0, 197) + "..." : cleanSummary;
embed.setDescription(truncated);
}
fields.push({
name: `🏷️ ${this.t(msg, "responses.lastfm.trackFieldTags")}`,
value: tagStr,
inline: false,
});
}
let similarTracks = [];
try {
similarTracks = await lastfm.getSimilarTracks(artistName, trackName, 5);
similarTracks = await lastfm.getSimilarTracks(artistName, trackName, 4);
} catch(e) { logger.warn("[LastFm] Error:", e?.message); }
if (similarTracks.length) {
const simStr = similarTracks.map(t => {
const matchPct = Math.round(t.match * 100);
const link = t.url ? `[${t.name}](${t.url})` : t.name;
return `${link} by **${t.artist}** (${matchPct}%)`;
return `${link} — **${t.artist}** \`(${matchPct}% match)\``;
}).join("\n");
embed.addFields({ name: "Similar Tracks", value: simStr.slice(0, 1024), inline: false });
fields.push({
name: `✨ ${this.t(msg, "responses.lastfm.trackFieldSimilar")}`,
value: simStr.slice(0, 1024),
inline: false,
});
}
embed.setFooter({ text: `Last.fm: ${user.username}` });
embed.addFields(...fields);
embed.setFooter({
text: this.t(msg, "responses.lastfm.trackFooterPro", {
prefix,
user: user.username,
track: info.name,
artist: artistName,
}),
});
return msg.reply({ embeds: [embed] });
}
+37 -15
View File
@@ -36,25 +36,32 @@ export const LISTENING_ACTIONS = new Set([
* @param {function(string, object=): string} tr - Translator bound to the invoking message.
* @param {boolean} [showPlaycount=false] - Whether to show play counts.
* @param {string} [prefix="%"] - The command prefix for the footer hint.
* @param {string|null} [authorName=null] - Optional author header text.
* @returns {EmbedBuilder} The constructed embed.
*/
function buildTrackList(username, title, tracks, tr, showPlaycount = false, prefix = "%") {
function buildTrackList(username, title, tracks, tr, showPlaycount = false, prefix = "%", authorName = null) {
const lines = tracks.map((t, i) => {
const num = String(i + 1).padStart(2, " ");
const num = String(i + 1).padStart(2, "0");
let name = t.name;
if (name.length > 40) name = name.slice(0, 37) + "...";
const link = t.url ? `[${name}](${t.url})` : name;
const extra = showPlaycount && t.playcount ? ` (${t.playcount} ${tr("responses.lastfm.plays")})` : "";
const extra = showPlaycount && t.playcount ? ` \`(${t.playcount} ${tr("responses.lastfm.plays")})\`` : "";
return `\`${num}.\` ${link} — **${t.artist}**${extra}`;
});
const desc = lines.join("\n").slice(0, 4096);
return new EmbedBuilder()
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(title) /* locale titles (lovedTitle/topTitle/recentTitle) already embed {{username}} */
.setDescription(desc)
.setFooter({ text: tr("responses.lastfm.trackListFooter", { prefix }) });
if (authorName) {
embed.setAuthor({ name: authorName });
}
return embed;
}
/**
@@ -70,29 +77,43 @@ function buildTrackList(username, title, tracks, tr, showPlaycount = false, pref
* @returns {EmbedBuilder} The constructed embed.
*/
function buildLeaderboardEmbed(lb, pageIdx, prefix, tr, opts = {}) {
const MEDALS = ["🥇", "🥈", "🥉"];
const startRank = pageIdx * lb.perPage;
const requesterId = opts.requesterId ? String(opts.requesterId) : null;
const lines = lb.entries.map((entry, i) => {
const rank = startRank + i + 1;
const head = rank <= 3 ? `${MEDALS[rank - 1]} ` : "";
const who = entry.userId ? `<@${entry.userId}>` : (entry.username || "?");
const lfName = entry.username ? ` — *${entry.username}*` : "";
const lfName = entry.username ? ` (*${entry.username}*)` : "";
const marker = requesterId && String(entry.userId) === requesterId ? ` **${tr("responses.lastfm.leaderboardYou")}**` : "";
const count = Utils.formatNumber(entry.scrobbleCount);
return `${head}**${rank}.** ${who}${lfName} — **${count}** ${tr("responses.lastfm.leaderboardScrobbles")}${marker}`;
if (rank === 1) {
return `🥇 **#1 ${tr("responses.lastfm.leaderboardChampion")}**\n> ${who}${lfName} — **${count}** ${tr("responses.lastfm.leaderboardScrobbles")}${marker}`;
}
if (rank === 2) {
return `🥈 **#2** ${who}${lfName} — **${count}** ${tr("responses.lastfm.leaderboardScrobbles")}${marker}`;
}
if (rank === 3) {
return `🥉 **#3** ${who}${lfName} — **${count}** ${tr("responses.lastfm.leaderboardScrobbles")}${marker}`;
}
const num = String(rank).padStart(2, "0");
return `\`${num}.\` ${who}${lfName} — **${count}** ${tr("responses.lastfm.leaderboardScrobbles")}${marker}`;
});
const desc = (lines.join("\n") + (opts.extraLine ? `\n\n${opts.extraLine}` : "")).slice(0, 4096);
let desc = lines.join("\n\n");
if (opts.extraLine) {
desc += `\n\n────────────────────\n${opts.extraLine}`;
}
const title = lb.scope === "server"
? tr("responses.lastfm.leaderboardTitleServer")
: tr("responses.lastfm.leaderboardTitleGlobal");
return new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: tr("responses.lastfm.leaderboardAuthorPro") })
.setTitle(title)
.setDescription(desc)
.setDescription(desc.slice(0, 4096))
.setFooter({ text: tr("responses.lastfm.leaderboardFooterSync", { prefix }) });
}
@@ -130,7 +151,7 @@ export async function runListeningActions(msg, data, lastfm, prefix, userId, tar
});
}
return msg.reply({ embeds: [buildTrackList(user.username, tr("responses.lastfm.lovedTitle", { username: user.username }), tracks, tr, false, prefix)] });
return msg.reply({ embeds: [buildTrackList(user.username, tr("responses.lastfm.lovedTitle", { username: user.username }), tracks, tr, false, prefix, tr("responses.lastfm.trackListAuthorLoved"))] });
}
case "top": {
@@ -155,7 +176,7 @@ export async function runListeningActions(msg, data, lastfm, prefix, userId, tar
}
const periodLabel = period !== "overall" ? ` (${period})` : "";
return msg.reply({ embeds: [buildTrackList(user.username, tr("responses.lastfm.topTitle", { username: user.username }) + periodLabel, tracks, tr, true, prefix)] });
return msg.reply({ embeds: [buildTrackList(user.username, tr("responses.lastfm.topTitle", { username: user.username }) + periodLabel, tracks, tr, true, prefix, tr("responses.lastfm.trackListAuthorTop"))] });
}
case "leaderboard":
@@ -273,7 +294,7 @@ export async function runListeningActions(msg, data, lastfm, prefix, userId, tar
});
}
return msg.reply({ embeds: [buildTrackList(user.username, tr("responses.lastfm.recentTitle", { username: user.username }), tracks, tr, false, prefix)] });
return msg.reply({ embeds: [buildTrackList(user.username, tr("responses.lastfm.recentTitle", { username: user.username }), tracks, tr, false, prefix, tr("responses.lastfm.trackListAuthorRecent"))] });
}
case "artists": {
@@ -299,7 +320,7 @@ export async function runListeningActions(msg, data, lastfm, prefix, userId, tar
const periodLabel = period !== "overall" ? ` (${period})` : "";
const lines = artists.map((a, i) => {
const num = String(i + 1).padStart(2, " ");
const num = String(i + 1).padStart(2, "0");
let name = a.name;
if (name.length > 40) name = name.slice(0, 37) + "...";
const link = a.url ? `[${name}](${a.url})` : name;
@@ -311,7 +332,8 @@ export async function runListeningActions(msg, data, lastfm, prefix, userId, tar
return msg.reply({
embeds: [new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(tr("responses.lastfm.artistsTitle", { username: user.username }) + periodLabel)
.setAuthor({ name: tr("responses.lastfm.artistsTitle", { username: user.username }) })
.setTitle(`🎤 ${tr("responses.lastfm.artistsTitle", { username: user.username })}${periodLabel}`)
.setDescription(desc)
.setFooter({ text: tr("responses.lastfm.artistsFooter", { prefix }) })]
});
+59 -49
View File
@@ -109,9 +109,12 @@ export async function playLastFmCategory(ctx, msg, userId, category, options = {
let statusMsg;
try {
statusMsg = await msg.reply({
embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(
`${categoryEmoji} Fetching your ${categoryLabel} tracks from Last.fm${resolveLabel}...`
)]
embeds: [new EmbedBuilder().setColor(getGlobalColor())
.setAuthor({ name: ctx.t(msg, "responses.lastfm.playDirectoryAuthor") })
.setTitle(ctx.t(msg, "responses.lastfm.playLoadingTitle"))
.setDescription(
`${categoryEmoji} Fetching your ${categoryLabel} tracks from Last.fm${resolveLabel}...`
)]
});
} catch (e) { logger.warn("[LastfmCmd] Error:", e?.message); statusMsg = null; }
@@ -128,9 +131,11 @@ export async function playLastFmCategory(ctx, msg, userId, category, options = {
}
if (!result.tracks.length) {
const noTracks = { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(
`${categoryEmoji} No ${categoryLabel.toLowerCase()} tracks found for **${result.username}**.`
)] };
const noTracks = { embeds: [new EmbedBuilder().setColor(getGlobalColor())
.setAuthor({ name: ctx.t(msg, "responses.lastfm.playDirectoryAuthor") })
.setDescription(
`${categoryEmoji} No ${categoryLabel.toLowerCase()} tracks found for **${result.username}**.`
)] };
if (statusMsg) statusMsg.edit(noTracks).catch(() => msg.reply(noTracks));
else msg.reply(noTracks);
return;
@@ -141,9 +146,18 @@ export async function playLastFmCategory(ctx, msg, userId, category, options = {
if (statusMsg) {
statusMsg.edit({
embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(
`${categoryEmoji} Loading **${result.tracks.length}** ${categoryLabel.toLowerCase()} tracks from **${result.username}**${resolveLabel}...`
)]
embeds: [new EmbedBuilder().setColor(getGlobalColor())
.setAuthor({ name: ctx.t(msg, "responses.lastfm.playDirectoryAuthor") })
.setTitle(ctx.t(msg, "responses.lastfm.playLoadingTitle"))
.setDescription(
ctx.t(msg, "responses.lastfm.playLoadingDesc", {
emoji: categoryEmoji,
count: result.tracks.length,
category: categoryLabel.toLowerCase(),
username: result.username,
provider: resolveLabel,
})
)]
}).catch(() => {});
}
@@ -168,12 +182,17 @@ export async function playLastFmCategory(ctx, msg, userId, category, options = {
}
const summary = [];
if (added > 0) summary.push(`✅ Added **${added}** track${added !== 1 ? "s" : ""} to the queue`);
if (failed > 0) summary.push(`⚠️ ${failed} track${failed !== 1 ? "s" : ""} couldn't be found`);
if (added > 0) summary.push(`✅ ${ctx.t(msg, "responses.lastfm.playDoneAdded", { count: added })}`);
if (failed > 0) summary.push(`⚠️ ${ctx.t(msg, "responses.lastfm.playDoneNotFound", { count: failed })}`);
const doneEmbed = { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(
`${categoryEmoji} **${categoryLabel} Tracks — ${result.username}**\n${summary.join(" · ")}`
)] };
const doneEmbed = { embeds: [new EmbedBuilder().setColor(getGlobalColor())
.setAuthor({ name: ctx.t(msg, "responses.lastfm.playDirectoryAuthor") })
.setTitle(ctx.t(msg, "responses.lastfm.playDoneTitle"))
.setDescription(
`${categoryEmoji} **${categoryLabel} Tracks — ${result.username}**\n\n` +
summary.join("\n")
)
.setFooter({ text: ctx.t(msg, "responses.lastfm.playDirectoryFooter", { prefix }) })] };
if (statusMsg) statusMsg.edit(doneEmbed).catch(() => msg.reply(doneEmbed));
else msg.reply(doneEmbed);
@@ -278,42 +297,33 @@ export async function runPlaybackActions(msg, data, lastfm, prefix, userId, targ
if (!parsed.category) {
const lfProviderNote = parsed.showAllCategories && parsed.resolveProvider
? `\n\n💡 \`${prefix}lastfm play ${parsed.resolveProvider}:<category>\` — Specify a category after the provider:`
? `\n💡 \`${prefix}lastfm play ${parsed.resolveProvider}:<category>\``
: "";
return msg.reply({
embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription([
`❌ Usage: \`${prefix}lastfm play <category>\``,
``,
`**Categories:**`,
`\`loved\` — Play your loved tracks`,
`\`top\` — Play your top tracks`,
`\`recent\` — Play your recent tracks`,
`\`albums\` — Play your top albums`,
`\`artists\` — Play your top artists' tracks`,
`\`playlist <number>\` — Play a playlist (use \`${prefix}lastfm playlists\` to list)`,
``,
`**With a search provider (defaults to \`top\`):**`,
`\`${prefix}lastfm play td\` or \`${prefix}lastfm play td:top\` — Play top tracks, search on Tidal`,
`\`${prefix}lastfm play sp\` or \`${prefix}lastfm play sp:top\` — Play top tracks, search on Spotify`,
`\`${prefix}lastfm play dz\` or \`${prefix}lastfm play dz:top\` — Play top tracks, search on Deezer`,
`\`${prefix}lastfm play yt\` or \`${prefix}lastfm play yt:top\` — Play top tracks, search on YouTube`,
``,
`**Last.fm as resolve provider (all categories):**`,
`\`${prefix}lastfm play lf:loved\` — Play loved tracks, search on Last.fm`,
`\`${prefix}lastfm play lf:top\` — Play top tracks, search on Last.fm`,
`\`${prefix}lastfm play lf:recent\` — Play recent tracks, search on Last.fm`,
`\`${prefix}lastfm play lf:albums\` — Play top albums, search on Last.fm`,
`\`${prefix}lastfm play lf:artists\` — Play top artists, search on Last.fm`,
``,
`**Examples:**`,
`\`${prefix}lastfm play loved\``,
`\`${prefix}lastfm play td\``,
`\`${prefix}lastfm play sp:top\``,
`\`${prefix}lastfm play lf:loved\``,
`\`${prefix}lastfm play playlist 1\``,
lfProviderNote,
].join("\n"))]
});
const directoryEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.lastfm.playDirectoryAuthor") })
.setTitle(this.t(msg, "responses.lastfm.playDirectoryTitle"))
.setDescription(
`\`${prefix}lastfm play <category> [provider]\`\n\n` +
`**${this.t(msg, "responses.lastfm.playDirectoryCollections")}:**\n` +
`• \`loved\` — ${this.t(msg, "responses.lastfm.playCategoryLoved")}\n` +
`• \`top\` — ${this.t(msg, "responses.lastfm.playCategoryTop")}\n` +
`• \`recent\` — ${this.t(msg, "responses.lastfm.playCategoryRecent")}\n` +
`• \`albums\` — ${this.t(msg, "responses.lastfm.playCategoryAlbums")}\n` +
`• \`artists\` — ${this.t(msg, "responses.lastfm.playCategoryArtists")}\n` +
`• \`playlist <num>\` — ${this.t(msg, "responses.lastfm.playCategoryPlaylist")}`
)
.addFields({
name: `🌐 ${this.t(msg, "responses.lastfm.playDirectoryProviders")}`,
value:
"`sp` (Spotify) · `td` (Tidal) · `dz` (Deezer) · `yt` (YouTube) · `lf` (Last.fm)\n" +
`*Examples:* \`${prefix}fm play loved\` · \`${prefix}fm play td:top\` · \`${prefix}fm play lf:loved\`${lfProviderNote}`,
inline: false,
})
.setFooter({ text: this.t(msg, "responses.lastfm.playDirectoryFooter", { prefix }) });
return msg.reply({ embeds: [directoryEmbed] });
}
return playLastFmCategory(this, msg, userId, parsed.category, {
+43 -26
View File
@@ -75,39 +75,56 @@ export async function runTagActions(msg, data, lastfm, prefix, userId, targetUse
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(`🏷️ ${tagInfo.name}`)
.setURL(tagInfo.url || undefined);
const fields = [];
fields.push({ name: "Reach", value: Utils.formatNumber(tagInfo.reach), inline: true });
fields.push({ name: "Total Taggings", value: Utils.formatNumber(tagInfo.count), inline: true });
if (topArtists.length) {
const artistStr = topArtists.map((a, i) => {
const link = a.url ? `[${a.name}](${a.url})` : a.name;
return `${i + 1}. ${link} (**${Utils.formatNumber(a.playcount)}** ${this.t(msg, "responses.lastfm.plays")})`;
}).join("\n");
fields.push({ name: "Top Artists", value: artistStr.slice(0, 1024), inline: false });
}
if (topTracks.length) {
const trackStr = topTracks.map((t, i) => {
const link = t.url ? `[${t.name}](${t.url})` : t.name;
return `${i + 1}. ${link} by **${t.artist}**`;
}).join("\n");
fields.push({ name: "Top Tracks", value: trackStr.slice(0, 1024), inline: false });
}
embed.addFields(...fields);
.setAuthor({ name: this.t(msg, "responses.lastfm.tagAuthor") })
.setTitle(tagInfo.name)
.setURL(tagInfo.url || undefined)
.setFooter({ text: this.t(msg, "responses.lastfm.tagFooterPro", { tag: tagInfo.name }) });
if (tagInfo.summary) {
const cleanSummary = tagInfo.summary.replace(/<[^>]*>/g, "").trim();
if (cleanSummary.length > 0) {
const truncated = cleanSummary.length > 300 ? cleanSummary.slice(0, 297) + "..." : cleanSummary;
embed.setDescription(truncated);
const truncated = cleanSummary.length > 280 ? cleanSummary.slice(0, 277) + "..." : cleanSummary;
embed.setDescription(`> *${truncated}*`);
}
}
embed.addFields(
{
name: this.t(msg, "responses.lastfm.tagFieldReach"),
value: `👥 **${Utils.formatNumber(tagInfo.reach)}**`,
inline: true
},
{
name: this.t(msg, "responses.lastfm.tagFieldTaggings"),
value: `🏷️ **${Utils.formatNumber(tagInfo.count)}**`,
inline: true
}
);
if (topArtists.length) {
const artistStr = topArtists.slice(0, 5).map((a, i) => {
const link = a.url ? `[${a.name}](${a.url})` : a.name;
return `\`${i + 1}.\` ${link} (${Utils.formatNumber(a.playcount)} ${this.t(msg, "responses.lastfm.plays")})`;
}).join(" · ");
embed.addFields({
name: this.t(msg, "responses.lastfm.tagFieldPillars"),
value: artistStr.slice(0, 1024),
inline: false
});
}
if (topTracks.length) {
const trackStr = topTracks.slice(0, 5).map((t, i) => {
const link = t.url ? `[${t.name}](${t.url})` : t.name;
return `\`${i + 1}.\` ${link} — **${t.artist}**`;
}).join("\n");
embed.addFields({
name: this.t(msg, "responses.lastfm.tagFieldTopTracks"),
value: trackStr.slice(0, 1024),
inline: false
});
}
return msg.reply({ embeds: [embed] });
}
+60 -23
View File
@@ -192,25 +192,40 @@ export async function runWhoknowsActions(msg, data, lastfm, prefix, userId, targ
});
}
const pct = Math.min(100, Math.max(0, Math.round(comparison.matchPercentage ?? 0)));
const filledBars = Math.round(pct / 10);
const emptyBars = 10 - filledBars;
const bar = "█".repeat(filledBars) + "░".repeat(emptyBars);
let level = "Low";
if (pct >= 80) level = "Super";
else if (pct >= 60) level = "High";
else if (pct >= 40) level = "Medium";
else if (pct >= 20) level = "Fair";
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(this.t(msg, "responses.lastfm.compareTitle"))
.setDescription([
`**${comparison.user1.username}** vs **${comparison.user2.username}**`,
``,
`📊 **${comparison.matchPercentage}%** match`,
``,
`👤 ${comparison.user1.username}: ${comparison.user1.totalArtists} top artists`,
`👤 ${comparison.user2.username}: ${comparison.user2.totalArtists} top artists`,
].join("\n"));
.setAuthor({ name: this.t(msg, "responses.lastfm.compareAuthor") })
.setTitle(`${comparison.user1.username} & ${comparison.user2.username}`)
.setDescription(
`📊 **[${bar}] ${pct}% MATCH**\n` +
`*${this.t(msg, "responses.lastfm.compareMeter", { level, score: pct })}*\n\n` +
`👤 **${comparison.user1.username}**: ${Utils.formatNumber(comparison.user1.totalArtists)} artists · ` +
`👤 **${comparison.user2.username}**: ${Utils.formatNumber(comparison.user2.totalArtists)} artists`
)
.setFooter({ text: this.t(msg, "responses.lastfm.compareFooterPro", { prefix }) });
if (comparison.commonArtists?.length) {
const commonStr = comparison.commonArtists.slice(0, 15).map((a, i) => {
const commonStr = comparison.commonArtists.slice(0, 10).map((a, i) => {
const num = String(i + 1).padStart(2, " ");
const link = a.url ? `[${a.name}](${a.url})` : a.name;
return `\`${num}.\` ${link} (**${a.playcount}** ${this.t(msg, "responses.lastfm.plays")})`;
return `\`${num}.\` ${link} — **${Utils.formatNumber(a.playcount)}** ${this.t(msg, "responses.lastfm.plays")}`;
}).join("\n");
embed.addFields({ name: `Common Artists (${comparison.commonArtists.length})`, value: commonStr.slice(0, 1024), inline: false });
embed.addFields({
name: `${this.t(msg, "responses.lastfm.compareFieldShared")} (${comparison.commonArtists.length})`,
value: commonStr.slice(0, 1024),
inline: false
});
}
return msg.reply({ embeds: [embed] });
@@ -340,22 +355,44 @@ export async function runWhoknowsActions(msg, data, lastfm, prefix, userId, targ
filteredCrowns = crowns.slice(0, 10);
}
const lines = filteredCrowns.slice(0, 20).map(c => {
const link = c.artistUrl ? `[${c.artist}](${c.artistUrl})` : c.artist;
const nextStr = c.nextBest ? ` (next: **${c.nextBest.username}** with ${Utils.formatNumber(c.nextBest.playcount)})` : "";
return `👑 ${link} — **${Utils.formatNumber(c.userPlaycount)}** ${this.t(msg, "responses.lastfm.plays")}${nextStr}`;
});
const desc = lines.join("\n").slice(0, 4096);
const topCrown = filteredCrowns[0];
const rest = filteredCrowns.slice(1, 15);
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.lastfm.crownsAuthor") })
.setTitle(this.t(msg, "responses.lastfm.crownsTitle", { username: user.username }))
.setDescription(desc)
.setFooter({ text: this.t(msg, "responses.lastfm.crownsFooter", { count: filteredCrowns.length, plural: filteredCrowns.length !== 1 ? "s" : "" }) });
.setFooter({ text: this.t(msg, "responses.lastfm.crownsFooterPro", { prefix }) });
if (filteredCrowns[0]?.image) {
embed.setThumbnail(filteredCrowns[0].image);
if (topCrown) {
const topLink = topCrown.artistUrl ? `[${topCrown.artist}](${topCrown.artistUrl})` : topCrown.artist;
let leadDesc = this.t(msg, "responses.lastfm.crownsUncontested");
if (topCrown.nextBest && topCrown.nextBest.playcount > 0) {
const lead = topCrown.userPlaycount - topCrown.nextBest.playcount;
leadDesc = `${this.t(msg, "responses.lastfm.crownsLead", { lead: Utils.formatNumber(lead) })} · ${this.t(msg, "responses.lastfm.crownsRunnerUp", { user: topCrown.nextBest.username, plays: Utils.formatNumber(topCrown.nextBest.playcount) })}`;
}
embed.addFields({
name: `👑 ${this.t(msg, "responses.lastfm.crownsMonopolyField")}`,
value: `**${topLink}** — **${Utils.formatNumber(topCrown.userPlaycount)}** ${this.t(msg, "responses.lastfm.plays")}\n*${leadDesc}*`,
inline: false
});
}
if (rest.length > 0) {
const otherLines = rest.map(c => {
const link = c.artistUrl ? `[${c.artist}](${c.artistUrl})` : c.artist;
const runner = c.nextBest ? ` (${c.nextBest.username}: ${Utils.formatNumber(c.nextBest.playcount)})` : "";
return `👑 ${link} — **${Utils.formatNumber(c.userPlaycount)}**${runner}`;
});
embed.addFields({
name: `🏛️ ${this.t(msg, "responses.lastfm.crownsOtherField")} (${filteredCrowns.length})`,
value: otherLines.join("\n").slice(0, 1024),
inline: false
});
}
if (topCrown?.image) {
embed.setThumbnail(topCrown.image);
}
const replyPayload = { embeds: [embed] };