From 64e69275a4c4823e5f0f76201ac113130862f784 Mon Sep 17 00:00:00 2001 From: NoLogicAlan Date: Thu, 22 Oct 2026 03:09:21 +0300 Subject: [PATCH] style(stats): overhaul embed into multi-column grid with bot thumbnail and localized categories --- commands/stats.mjs | 88 +++++++++++++++++++++++++--------- src/music/player/Player.mjs | 1 - storage/locales/bot/ar-SA.json | 4 ++ storage/locales/bot/ckb.json | 4 ++ storage/locales/bot/de-DE.json | 4 ++ storage/locales/bot/en.json | 4 ++ storage/locales/bot/pt-BR.json | 4 ++ storage/locales/bot/tr.json | 4 ++ 8 files changed, 90 insertions(+), 23 deletions(-) diff --git a/commands/stats.mjs b/commands/stats.mjs index ef7e312..896eddd 100644 --- a/commands/stats.mjs +++ b/commands/stats.mjs @@ -320,6 +320,8 @@ function tOr(t, msg, key, fallback, vars = {}) { /** * Build the stats embed with all bot information. + * Uses a clean multi-column grid layout (addFields) with category sections + * and a top-right bot avatar thumbnail. * @private * @param {Function} t - Translation function. * @param {object} msg - The command message wrapper. @@ -331,6 +333,7 @@ function tOr(t, msg, key, fallback, vars = {}) { * @param {number} s.queuedTracks - Total tracks across all player queues. * @param {number} s.radios247 - Number of active 24/7 radio sessions. * @param {string} s.shard - Shard assignment string. + * @param {string|null} [s.botIcon] - Bot avatar URL. * @param {number} s.scrobbleCount - Total Last.fm scrobbles. * @param {number} s.linkedUsers - Number of Last.fm linked users. * @param {number} s.ping - Bot response ping in ms (REST reply round trip). @@ -355,41 +358,80 @@ function buildEmbed(t, msg, s, pending = []) { }) : num(s.playerCount); - const description = [ + const fields = []; + + const overviewLines = [ `${t(msg, "responses.stats.servers")} — ${field("guilds", num(s.guildCount))}`, `${t(msg, "responses.stats.users")} — ${field("users", num(s.userCount))}`, - `${t(msg, "responses.stats.players")} — ${field("players", playerVal)}`, - `${tOr(t, msg, "responses.stats.queuedTracks", "🎶 **Queued Tracks**")} — ${field("queuedTracks", num(s.queuedTracks))}`, - s.radios247 > 0 ? `${tOr(t, msg, "responses.stats.radios", "📻 **24/7 Radios**")} — ${field("radios", num(s.radios247))}` : null, + `${tOr(t, msg, "responses.stats.shard", "🧩 **Shard**")} — \`${s.shard}\``, ]; + fields.push({ + name: tOr(t, msg, "responses.stats.categoryOverview", "📊 Overview"), + value: overviewLines.join("\n"), + inline: true, + }); + + const musicLines = [ + `${t(msg, "responses.stats.players")} — ${field("players", playerVal)}`, + ]; + if (s.queuedTracks > 0) { + musicLines.push(`${tOr(t, msg, "responses.stats.queuedTracks", "🎶 **Queued Tracks**")} — ${field("queuedTracks", num(s.queuedTracks))}`); + } + if (s.radios247 > 0) { + musicLines.push(`${tOr(t, msg, "responses.stats.radios", "📻 **24/7 Radios**")} — ${field("radios", num(s.radios247))}`); + } + fields.push({ + name: tOr(t, msg, "responses.stats.categoryMusic", "🎧 Music Activity"), + value: musicLines.join("\n"), + inline: true, + }); if (s.lastfmEnabled) { - description.push( - `${t(msg, "responses.stats.scrobbles")} — ${field("scrobbles", num(s.scrobbleCount))}`, - `${t(msg, "responses.stats.linkedUsers")} — ${field("linkedUsers", num(s.linkedUsers))}`, - ); + const lastfmLines = [ + `${t(msg, "responses.stats.scrobbles")} — ${field("scrobbles", num(s.scrobbleCount))}`, + `${t(msg, "responses.stats.linkedUsers")} — ${field("linkedUsers", num(s.linkedUsers))}`, + ]; + fields.push({ + name: tOr(t, msg, "responses.stats.categoryLastfm", "🎵 Last.fm"), + value: lastfmLines.join("\n"), + inline: true, + }); } - description.push( - `${t(msg, "responses.stats.ping")} — ${field("ping", `${num(s.ping)}ms`)}`, - s.gatewayPing >= 0 ? `${tOr(t, msg, "responses.stats.gateway", GATEWAY_FALLBACK_LABEL)} — \`${num(s.gatewayPing)}ms\`` : null, - `${tOr(t, msg, "responses.stats.shard", "🧩 **Shard**")} — \`${s.shard}\``, - `${t(msg, "responses.stats.uptime")} — \`${s.uptime}\``, - `${t(msg, "responses.stats.build")} — [\`${s.comHash}\`](${s.comLink})`, - s.reason ? `${t(msg, "responses.stats.lastRestart")} — \`${s.reason}\`` : null, - ``, - t(msg, "responses.stats.supportKofi"), - t(msg, "responses.stats.community"), - ); + const perfLines = [ + `${t(msg, "responses.stats.ping")} — ${field("ping", `${num(s.ping)}ms`)}`, + ]; + if (s.gatewayPing >= 0) { + perfLines.push(`${tOr(t, msg, "responses.stats.gateway", GATEWAY_FALLBACK_LABEL)} — \`${num(s.gatewayPing)}ms\``); + } + perfLines.push(`${t(msg, "responses.stats.uptime")} — \`${s.uptime}\``); + fields.push({ + name: tOr(t, msg, "responses.stats.categoryPerformance", "⚡ System & Network"), + value: perfLines.join("\n"), + inline: true, + }); - const desc = description.filter(l => l !== null).join("\n"); + const descLines = [ + `${t(msg, "responses.stats.build")} — [\`${s.comHash}\`](${s.comLink})` + + (s.reason ? ` • ${t(msg, "responses.stats.lastRestart")} — \`${s.reason}\`` : ""), + ``, + `${t(msg, "responses.stats.supportKofi")} • ${t(msg, "responses.stats.community")}`, + ]; + + const authorOptions = { name: t(msg, "responses.stats.title") }; + if (s.botIcon) authorOptions.iconURL = s.botIcon; const builder = new EmbedBuilder() .setColor(getGlobalColor()) - .setAuthor({ name: t(msg, "responses.stats.title") }) - .setDescription(desc) + .setAuthor(authorOptions) + .setDescription(descLines.join("\n")) + .addFields(fields) .setFooter({ text: s.footer || t(msg, "responses.stats.title") }); + if (s.botIcon) { + builder.setThumbnail(s.botIcon); + } + if (typeof builder.setTimestamp === "function") builder.setTimestamp(); return builder; } @@ -411,6 +453,7 @@ export async function run(message) { const totals = getTotals(this.client); const music = getMusicStats(this.players?.playerMap); const shard = getShardInfo(this.client, message.guildId ?? message.guild?.id); + const botIcon = this.client?.user?.displayAvatarURL?.() || this.client?.user?.avatarURL?.() || null; scheduleBackgroundRefresh(this.client, lastfmEnabled ? lastfm : null); @@ -430,6 +473,7 @@ export async function run(message) { queuedTracks: music.queuedTracks, radios247: music.radios247, shard, + botIcon, scrobbleCount: lastfmEnabled ? (cache.scrobbles ?? 0) : 0, linkedUsers: lastfmEnabled ? (cache.linkedUsers ?? 0) : 0, lastfmEnabled, diff --git a/src/music/player/Player.mjs b/src/music/player/Player.mjs index 2757de1..e464a89 100644 --- a/src/music/player/Player.mjs +++ b/src/music/player/Player.mjs @@ -516,7 +516,6 @@ class Player extends EventEmitter { this._lastConnectedAt = Date.now(); this.leaving = false; - // Fail-fast permission check before initiating gateway voice handshake try { const me = channel.guild?.members?.me ?? (this.client?.user?.id ? channel.guild?.members?.get?.(this.client.user.id) : null); if (me) { diff --git a/storage/locales/bot/ar-SA.json b/storage/locales/bot/ar-SA.json index 9e4710b..ea259d5 100644 --- a/storage/locales/bot/ar-SA.json +++ b/storage/locales/bot/ar-SA.json @@ -611,6 +611,10 @@ }, "stats": { "title": "بوت Remix الموسيقي", + "categoryOverview": "📊 نظرة عامة", + "categoryMusic": "🎧 النشاط الموسيقي", + "categoryLastfm": "🎵 Last.fm", + "categoryPerformance": "⚡ النظام والشبكة", "servers": "📂 **الخوادم**", "users": "👥 **المستخدمون**", "players": "🎧 **المشغّلات**", diff --git a/storage/locales/bot/ckb.json b/storage/locales/bot/ckb.json index 92fa3f4..f677284 100644 --- a/storage/locales/bot/ckb.json +++ b/storage/locales/bot/ckb.json @@ -611,6 +611,10 @@ }, "stats": { "title": "بۆتی موزیکی Remix", + "categoryOverview": "📊 کورتە", + "categoryMusic": "🎧 چالاکی موزیک", + "categoryLastfm": "🎵 Last.fm", + "categoryPerformance": "⚡ سیستەم و هێڵ", "servers": "📂 **سێرڤەرەکان**", "users": "👥 **بەکارهێنەران**", "players": "🎧 **پەخشکەرەکان**", diff --git a/storage/locales/bot/de-DE.json b/storage/locales/bot/de-DE.json index ca0cfbb..cad21ee 100644 --- a/storage/locales/bot/de-DE.json +++ b/storage/locales/bot/de-DE.json @@ -611,6 +611,10 @@ }, "stats": { "title": "Remix Musik-Bot", + "categoryOverview": "📊 Übersicht", + "categoryMusic": "🎧 Musik-Aktivität", + "categoryLastfm": "🎵 Last.fm", + "categoryPerformance": "⚡ System & Netzwerk", "servers": "📂 **Server**", "users": "👥 **Benutzer**", "players": "🎧 **Player**", diff --git a/storage/locales/bot/en.json b/storage/locales/bot/en.json index 4d55266..8f719ac 100644 --- a/storage/locales/bot/en.json +++ b/storage/locales/bot/en.json @@ -728,6 +728,10 @@ }, "stats": { "title": "Remix Music Bot", + "categoryOverview": "📊 Overview", + "categoryMusic": "🎧 Music Activity", + "categoryLastfm": "🎵 Last.fm", + "categoryPerformance": "⚡ System & Network", "servers": "📂 **Servers**", "users": "👥 **Users**", "players": "🎧 **Players**", diff --git a/storage/locales/bot/pt-BR.json b/storage/locales/bot/pt-BR.json index 3d65bae..719ff27 100644 --- a/storage/locales/bot/pt-BR.json +++ b/storage/locales/bot/pt-BR.json @@ -611,6 +611,10 @@ }, "stats": { "title": "Bot de Música Remix", + "categoryOverview": "📊 Visão Geral", + "categoryMusic": "🎧 Atividade Musical", + "categoryLastfm": "🎵 Last.fm", + "categoryPerformance": "⚡ Sistema e Rede", "servers": "📂 **Servidores**", "users": "👥 **Usuários**", "players": "🎧 **Players**", diff --git a/storage/locales/bot/tr.json b/storage/locales/bot/tr.json index ca79c48..25b5c90 100644 --- a/storage/locales/bot/tr.json +++ b/storage/locales/bot/tr.json @@ -717,6 +717,10 @@ }, "stats": { "title": "Remix Müzik Botu", + "categoryOverview": "📊 Genel Bakış", + "categoryMusic": "🎧 Müzik Aktivitesi", + "categoryLastfm": "🎵 Last.fm", + "categoryPerformance": "⚡ Sistem ve Ağ", "servers": "📂 **Sunucular**", "users": "👥 **Kullanıcılar**", "players": "🎧 **Oynatıcılar**",