feat(embeds): upgrade settings, 24/7 watchdog, and lastfm info embeds

- Upgrade %settings get to modular categorized Server Control Dashboard
- Upgrade %247 panel to live voice watchdog and connection health monitor
- Upgrade %fm profile to Last.fm music identity card with user avatar and stats
- Upgrade %fm artistinfo to artist spotlight card with tags, bio, and plays matrix
- Upgrade %fm cover to high-resolution album artwork gallery frame
- Add complete translations across all 6 locales (0 missing keys)
This commit is contained in:
NoLogicAlan committed 2026-10-25 04:16:36 +03:00
1 parent 63433816c4
commit 36b27d466b
11 files changed
+418 -332

No files matched your search

+35 -9
View File
@@ -190,17 +190,43 @@ export async function runAccountActions(msg, data, lastfm, prefix, userId, targe
lastfm.syncUserScrobbleCount(profileUserId).catch(() => {});
const avatarUrl = info.image?.[3]?.["#text"] || info.image?.[2]?.["#text"] || null;
const regDate = info.registered?.unixtime ? new Date(+info.registered.unixtime * 1000).toLocaleDateString() : "unknown";
const scrobbleStatus = user.scrobbleEnabled
? this.t(msg, "responses.lastfm.profileScrobbleEnabled")
: this.t(msg, "responses.lastfm.profileScrobbleDisabled");
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.lastfm.profileTitle", { username: info.name }), iconURL: info.image?.[2]?.["#text"] || undefined, url: info.url })
.setDescription([
this.t(msg, "responses.lastfm.profileScrobbles", { playcount: Utils.formatNumber(info.playcount ?? 0) }),
this.t(msg, "responses.lastfm.profileRegistered", { date: info.registered?.unixtime ? new Date(+info.registered.unixtime * 1000).toLocaleDateString() : "unknown" }),
this.t(msg, "responses.lastfm.profileScrobbleStatus", { status: user.scrobbleEnabled ? this.t(msg, "responses.lastfm.profileScrobbleEnabled") : this.t(msg, "responses.lastfm.profileScrobbleDisabled") }),
``,
this.t(msg, "responses.lastfm.profileLink", { url: info.url }),
].join("\n"))
.setFooter({ text: this.t(msg, "responses.lastfm.profileScrobbleFooter", { prefix }) });
.setAuthor({ name: this.t(msg, "responses.lastfm.profileAuthor"), iconURL: avatarUrl || undefined, url: info.url })
.setTitle(info.name)
.setURL(info.url || undefined)
.setDescription(
`📅 **${this.t(msg, "responses.lastfm.profileFieldRegistered")}:** ${regDate}\n` +
`🔗 **[${this.t(msg, "responses.lastfm.profileLink", { url: info.url })}](${info.url})**`
)
.addFields(
{
name: this.t(msg, "responses.lastfm.profileFieldTotalScrobbles"),
value: `🎵 **${Utils.formatNumber(info.playcount ?? 0)}**`,
inline: true
},
{
name: this.t(msg, "responses.lastfm.profileFieldArtists"),
value: `🎤 **${Utils.formatNumber(info.artist_count ?? 0)}**`,
inline: true
},
{
name: this.t(msg, "responses.lastfm.profileFieldScrobbling"),
value: scrobbleStatus,
inline: true
}
)
.setFooter({ text: this.t(msg, "responses.lastfm.profileFooterPro", { prefix }) });
if (avatarUrl) {
embed.setThumbnail(avatarUrl);
}
return msg.reply({ embeds: [embed] });
}
+28 -24
View File
@@ -102,44 +102,46 @@ export async function runInfoActions(msg, data, lastfm, prefix, userId, targetUs
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(`🎤 ${info.name}`)
.setAuthor({ name: this.t(msg, "responses.lastfm.artistSpotlightAuthor"), iconURL: info.image || undefined })
.setTitle(info.name)
.setURL(info.url || undefined)
.setThumbnail(info.image || undefined);
let desc = "";
if (info.tags?.length) {
const tagStr = info.tags.slice(0, 6).map(t => {
const tagLower = String(t).toLowerCase().replace(/\s+/g, "+");
return `[\`${t}\`](https://www.last.fm/tag/${encodeURIComponent(tagLower)})`;
}).join(" ");
desc += tagStr + "\n\n";
}
if (info.bio) {
const cleanBio = info.bio.replace(/<[^>]*>/g, "").trim();
if (cleanBio.length > 0) {
const truncated = cleanBio.length > 280 ? cleanBio.slice(0, 277) + "..." : cleanBio;
desc += `> ${truncated}`;
}
}
if (desc) embed.setDescription(desc.trim());
const fields = [];
fields.push({ name: "Listeners", value: Utils.formatNumber(info.stats?.listeners ?? 0), inline: true });
fields.push({ name: "Global Plays", value: Utils.formatNumber(info.stats?.playcount ?? 0), inline: true });
fields.push({ name: this.t(msg, "responses.lastfm.artistFieldListeners"), value: `👥 **${Utils.formatNumber(info.stats?.listeners ?? 0)}**`, inline: true });
fields.push({ name: this.t(msg, "responses.lastfm.artistFieldPlays"), value: `▶️ **${Utils.formatNumber(info.stats?.playcount ?? 0)}**`, inline: true });
if (info.userplaycount != null && user) {
fields.push({ name: "Your Plays", value: Utils.formatNumber(info.userplaycount), inline: true });
}
if (info.tags?.length) {
const tagStr = info.tags.slice(0, 8).map(t => {
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.artistFieldUserPlays"), value: `🎧 **${Utils.formatNumber(info.userplaycount)}**`, inline: true });
}
if (info.similar?.length) {
const simStr = info.similar.slice(0, 5).map(s => {
return s.url ? `[${s.name}](${s.url})` : s.name;
}).join(" · ");
fields.push({ name: "Similar Artists", value: simStr, inline: false });
fields.push({ name: this.t(msg, "responses.lastfm.artistFieldSimilar"), value: simStr, inline: false });
}
embed.addFields(...fields);
if (info.bio) {
const cleanBio = info.bio.replace(/<[^>]*>/g, "").trim();
if (cleanBio.length > 0) {
const truncated = cleanBio.length > 300 ? cleanBio.slice(0, 297) + "..." : cleanBio;
embed.setDescription(truncated);
}
}
embed.setFooter({ text: user ? `Last.fm: ${user.username}` : "Last.fm" });
embed.setFooter({ text: this.t(msg, "responses.lastfm.artistFooterPro", { artist: info.name }) });
return msg.reply({ embeds: [embed] });
}
@@ -494,9 +496,11 @@ export async function runInfoActions(msg, data, lastfm, prefix, userId, targetUs
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle(this.t(msg, "responses.lastfm.coverTitle", { album: albumTitle }))
.setAuthor({ name: this.t(msg, "responses.lastfm.coverAuthor") })
.setTitle(albumTitle)
.setDescription(`🎵 **${trackName}** ${String.fromCharCode(8212)} **${artistName}**`)
.setImage(coverUrl)
.setFooter({ text: this.t(msg, "responses.lastfm.coverFooter", { track: trackName, artist: artistName }) });
.setFooter({ text: this.t(msg, "responses.lastfm.coverFooterPro", { prefix }) });
return msg.reply({ embeds: [embed] });
}
+61 -19
View File
@@ -7,7 +7,8 @@
import { CommandBuilder } from "../src/commands/index.mjs";
import { getMessageGuildId } from "../src/ui/index.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getMessageGuildId, getGlobalColor } from "../src/ui/index.mjs";
import { logger } from "../src/core/Logger.mjs";
import {
SHORTCUTS, BOOL_SETTINGS, VALID_LOCALES, setValidLocales,
@@ -182,9 +183,19 @@ export async function run(message, data) {
const desc = this.settingsMgr.descriptions?.[settingKey];
const resolvedDesc = desc ? desc.replace(/\$prefix/gi, prefix) : null;
const label = prettifySettingLabel(settingKey, t247, guildId);
let reply = "**" + label + "**\nValue: " + displayValue(settingKey, val);
if (resolvedDesc) reply += "\n\n*" + resolvedDesc + "*";
return message.reply(embed(reply));
const inspEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(message, "responses.settings.inspectorTitle") })
.setTitle(label)
.addFields(
{ name: this.t(message, "responses.settings.settingValueField"), value: displayValue(settingKey, val), inline: true }
);
if (resolvedDesc) {
inspEmbed.addFields({ name: this.t(message, "responses.settings.settingDescField"), value: `*${resolvedDesc}*`, inline: false });
}
inspEmbed.setFooter({ text: this.t(message, "responses.settings.inspectorFooter", { prefix, setting: settingKey }) });
return message.reply({ embeds: [inspEmbed] });
}
const d = set.getAll();
@@ -195,22 +206,53 @@ export async function run(message, data) {
: null;
const channels = get247Channels(set);
const lines = this.settingsMgr.getPublicKeys()
.map(k => {
if (k === "stay_247") {
return "\u2022 **24/7 mode** " + String.fromCharCode(8212) + " " + (channels.size > 0
? channels.size + " channel(s)"
: "\u274c disabled");
}
const label = prettifySettingLabel(k, t247, guildId);
return "\u2022 **" + label + "** " + String.fromCharCode(8212) + " " + displayValue(k, d[k]);
});
return message.reply(embed(
this.t(message, "responses.settings.serverHeader", { name: guildName }) + "\n\n" + lines.join("\n") + "\n\n" +
this.t(message, "responses.settings.shortcutsHint", { prefix }),
{ title: this.t(message, "responses.settings.serverTitle"), iconURL: iconUrl }
));
/* Category 1: General & Localization */
const prefixVal = d.prefix ?? "%";
const localeVal = d.locale ?? "en";
const pfpVal = d.pfp ?? "default";
const generalLines = [
`• **${prettifySettingLabel("prefix", t247, guildId)}**: \`${prefixVal}\``,
`• **${prettifySettingLabel("locale", t247, guildId)}**: \`${localeVal}\``,
`• **${prettifySettingLabel("pfp", t247, guildId)}**: \`${pfpVal}\``
].join("\n");
/* Category 2: Audio & Playback */
const volVal = d.volume ?? 100;
const songAnnounce = d.songAnnouncements ?? true;
const normVal = d.normalize ?? true;
const voteSkipVal = d.voteSkip ?? true;
const voteLimit = d.voteSkipThreshold ?? 3;
const audioLines = [
`• **${prettifySettingLabel("volume", t247, guildId)}**: \`${volVal}%\``,
`• **${prettifySettingLabel("normalize", t247, guildId)}**: ${normVal ? "✅ enabled (EBU R128)" : "❌ disabled"}`,
`• **${prettifySettingLabel("songAnnouncements", t247, guildId)}**: ${songAnnounce ? "✅ enabled" : "❌ disabled"}`,
`• **${prettifySettingLabel("voteSkip", t247, guildId)}**: ${voteSkipVal ? `✅ enabled (≥${voteLimit})` : "❌ disabled"}`
].join("\n");
/* Category 3: 24/7 Voice Connection */
let voice247Text = "❌ disabled";
if (channels.size > 0) {
const chList = [...channels].map(id => `<#${id}>`).join(", ");
voice247Text = `🔊 ${chList} — **${this.t(message, "responses.settings.statusActive247")}**`;
}
const dashEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(message, "responses.settings.dashboardTitle") })
.setTitle(guildName)
.addFields(
{ name: this.t(message, "responses.settings.categoryGeneral"), value: generalLines, inline: false },
{ name: this.t(message, "responses.settings.categoryAudio"), value: audioLines, inline: false },
{ name: this.t(message, "responses.settings.categoryVoice247"), value: voice247Text, inline: false }
)
.setFooter({ text: this.t(message, "responses.settings.dashboardFooter", { prefix }) });
if (iconUrl) {
dashEmbed.setThumbnail(iconUrl);
}
return message.reply({ embeds: [dashEmbed] });
}
if (cmd === "resetSettings") {
+63 -15
View File
@@ -12,7 +12,8 @@
*/
import { cleanId } from "../../src/ui/index.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { cleanId, getGlobalColor } from "../../src/ui/index.mjs";
import { isPlayerConnectionDead } from "../../src/utils/Helpers247.mjs";
import { isValidFluxerId, MAX_247_CHANNELS, embed, tWrap } from "./utils.mjs";
@@ -161,11 +162,56 @@ function build247PanelDescription(set, ctx, guildId, justToggledId = null) {
export function build247Panel(set, ctx, guildId, justToggledId = null) {
const t = tWrap(ctx, guildId);
const prefix = ctx.handler.getPrefix(guildId);
const channels = [...get247Channels(set)];
const panelKey = (k, vars = {}) => t("responses.settings.247Panel." + k, vars);
return embed(
build247PanelDescription(set, ctx, guildId, justToggledId),
{ title: panelKey("title"), footer: panelKey("footerLine", { prefix }) }
);
const watchdog = ctx.gatewayHandler;
const watchdogOn = watchdog?.isWatchdog247Running?.() === true;
const sweepSeconds = Math.round((watchdog?._247WatchdogInterval ?? 60_000) / 1000);
const panelEmbed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: panelKey("watchdogAuthor") })
.setTitle(panelKey("watchdogTitle"))
.setFooter({ text: panelKey("watchdogFooter", { prefix }) });
if (channels.length === 0) {
panelEmbed.setDescription(
panelKey("disabledLine") + "\n\n" +
panelKey("allChannelsDisabled") + "\n\n" +
panelKey("disabledHint", { prefix })
);
} else {
const statuses = channels
.map(id => channelStatus(ctx, guildId, id, t))
.sort((a, b) => a.order - b.order);
const lines = statuses.map(s =>
s.line + (justToggledId && s.line.includes("<#" + cleanId(justToggledId) + ">") ? " \u2190" : "")
);
const allConnected = statuses.every(s => s.state === "connected");
const statusHeader = (channels.length === 1 && allConnected
? panelKey("enabledLine")
: panelKey(channels.length === 1 ? "activeChannels_one" : "activeChannels_other", { count: channels.length }));
panelEmbed.setDescription(statusHeader + "\n\n" + lines.join("\n"));
panelEmbed.addFields(
{
name: panelKey("watchdogFieldRecovery"),
value: watchdogOn ? panelKey("watchdogRecoveryArmed", { seconds: sweepSeconds }) : panelKey("autoRecoveryDisabledLine"),
inline: true
},
{
name: panelKey("watchdogFieldInactivity"),
value: panelKey("watchdogInactivitySuppressed"),
inline: true
}
);
}
return { embeds: [panelEmbed] };
}
/**
* Disable 24/7 mode for a specific channel.
@@ -269,17 +315,19 @@ export async function handle247Toggle(ctx, message, set, guildId) {
if (channels.has(id)) {
await disable247(ctx, set, guildId, userChannelId);
return message.reply(embed(
panelKey("confirmDisabled", { channel: "<#" + id + ">" }) + "\n\n" +
build247PanelDescription(set, ctx, guildId, null),
{ title: panelKey("title") }
));
const panel = build247Panel(set, ctx, guildId, null);
panel.embeds[0].setDescription(
panelKey("confirmDisabled", { channel: "<#" + id + ">" }) + "\n\n" +
panel.embeds[0].description
);
return message.reply(panel);
}
await enable247(ctx, set, guildId, userChannelId);
return message.reply(embed(
panelKey("confirmEnabled", { channel: "<#" + id + ">" }) + "\n\n" +
build247PanelDescription(set, ctx, guildId, id),
{ title: panelKey("title") }
));
const panel = build247Panel(set, ctx, guildId, id);
panel.embeds[0].setDescription(
panelKey("confirmEnabled", { channel: "<#" + id + ">" }) + "\n\n" +
panel.embeds[0].description
);
return message.reply(panel);
}
+3 -1
View File
@@ -27,7 +27,7 @@ const BOOL_TRUE = new Set(["true", "1", "yes", "on", "enable", "enabled"]);
/** @private @type {Set<string>} Strings that evaluate to boolean false. */
const BOOL_FALSE = new Set(["false", "0", "no", "off", "disable", "disabled"]);
/** @private @type {Set<string>} Setting keys that use boolean display formatting. */
export const BOOL_SETTINGS = new Set(["songAnnouncements", "voteSkip"]);
export const BOOL_SETTINGS = new Set(["songAnnouncements", "voteSkip", "normalize"]);
/** @private @type {Set<string>} Available locale codes, populated at load time. */
export let VALID_LOCALES = new Set(["en"]);
@@ -138,6 +138,7 @@ export function prettifySettingLabel(key, t, guildId) {
locale: "responses.settings.labelLocale",
stay_247: "responses.settings.label247",
volume: "responses.settings.labelVolume",
normalize: "responses.settings.labelNormalize",
voteSkip: "responses.settings.labelVoteSkip",
voteSkipThreshold: "responses.settings.labelVoteSkipThreshold",
};
@@ -149,6 +150,7 @@ export function prettifySettingLabel(key, t, guildId) {
locale: "Locale",
stay_247: "24/7 mode",
volume: "Default volume",
normalize: "Volume normalization",
voteSkip: "Vote to skip",
voteSkipThreshold: "Vote to skip threshold",
};