From 585a1035c00e0061a6648cc0730b3d0bb8855431 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 27 Oct 2024 15:31:12 +0000 Subject: [PATCH 1/8] its shiggy season --- index.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 9d34bcf..d2b7a27 100644 --- a/index.ts +++ b/index.ts @@ -101,10 +101,34 @@ function humanFileSize(bytes, si = false, dp = 1) { return bytes.toFixed(dp) + " " + units[u]; } +let BUILD_NUMBER; +let VERSION_HASH; + export default definePlugin({ name: "venfetch", description: "neofetch for vencord", authors: [Devs.nin0dev], + patches: [ + { + find: /.log\("[BUILD INFO]/, + replacement: [ + { + match: /Build Number: "\).concat\(("\d+")/, + replace: "Build Number: \").concat($self.setBuildNumber($1)" + }, + { + match: /Version Hash: \"\).concat\(("\w+")/, + replace: "Version Hash: \").concat($self.setVersionHash($1)" + } + ] + } + ], + setBuildNumber(buildNumber) { + return BUILD_NUMBER = buildNumber; + }, + setVersionHash(versionHash) { + return VERSION_HASH = versionHash; + }, commands: [ { name: "venfetch", @@ -115,8 +139,10 @@ export default definePlugin({ const info: Record = { version: `${VERSION} ~ ${gitHash}${SettingsPlugin.additionalInfo} - ${Intl.DateTimeFormat(navigator.language, { dateStyle: "medium" }).format(BUILD_TIMESTAMP)}`, client: `${t(window.GLOBAL_ENV.RELEASE_CHANNEL)} ~ ${clientVersion()}`, + // TODO: fix this + // build: `${BUILD_NUMBER ?? "Unknown"} (${VERSION_HASH?.slice(0, 7) ?? 'unknown'})`, // @ts-ignore - platform: navigator.userAgentData?.platform ?? navigator.platform, + platform: navigator.userAgentData?.platform ? `${navigator.userAgentData?.platform} (${navigator.platform})` : navigator.platform, plugins: getEnabledPlugins(), uptime: `${~~((Date.now() - uptime) / 1000)}s`, // TODO: pr to vencord real and add to vencordnative @@ -124,7 +150,7 @@ export default definePlugin({ _: null, donor: getDonorStatus() ? "yes" : "no", - contributor: getContribStatus() ? "yes" : null, + contributor: getContribStatus() ? "yes" : "no", __: null, From 59c84ebb5d274b679e79915f583422fe736379b4 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 27 Oct 2024 15:32:44 +0000 Subject: [PATCH 2/8] fix bug --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index d2b7a27..2bec7ed 100644 --- a/index.ts +++ b/index.ts @@ -67,7 +67,7 @@ function getEnabledPlugins() { let userpluginsCount = 0; Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => { - if (value.started) if (PluginMeta[value.name].userPlugin) userpluginsCount++; else counter++; + if (value.started) if (PluginMeta[value.name]?.userPlugin) userpluginsCount++; else counter++; }); return `${counter} (official)` + (userpluginsCount ? `, ${userpluginsCount} (userplugins)` : ""); From 5c867c19f986a21937f3607eeed412b06eedf5b2 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 27 Oct 2024 15:46:08 +0000 Subject: [PATCH 3/8] add build number --- index.ts | 59 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/index.ts b/index.ts index 2bec7ed..e7d32fd 100644 --- a/index.ts +++ b/index.ts @@ -14,6 +14,7 @@ import { GuildMemberStore, UserStore } from "@webpack/common"; import { PluginMeta } from "~plugins"; import SettingsPlugin from "../../plugins/_core/settings"; +import { findByCodeLazy } from "../../webpack/webpack.js"; const clientVersion = () => { const version = IS_DISCORD_DESKTOP ? DiscordNative.app.getVersion() : IS_VESKTOP ? VesktopNative.app.getVersion() : null; @@ -63,14 +64,28 @@ VV VV // ```; function getEnabledPlugins() { - let counter = 0; - let userpluginsCount = 0; + const counters = { + official: { + enabled: 0, + total: 0 + }, + user: { + enabled: 0, + total: 0 + } + } Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => { - if (value.started) if (PluginMeta[value.name]?.userPlugin) userpluginsCount++; else counter++; + if (PluginMeta[value.name]?.userPlugin) { + if (value.started) counters.user.enabled++; + counters.user.total++; + } else { + if (value.started) counters.official.enabled++; + counters.official.total++; + } }); - return `${counter} (official)` + (userpluginsCount ? `, ${userpluginsCount} (userplugins)` : ""); + return `${counters.official.enabled} / ${counters.official.total} (official)` + (counters.user.total ? `, ${counters.user.enabled} / ${counters.user.total} (userplugins)` : ""); } function getDonorStatus() { return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532"); @@ -104,31 +119,13 @@ function humanFileSize(bytes, si = false, dp = 1) { let BUILD_NUMBER; let VERSION_HASH; + +const getVersions = findByCodeLazy("logsUploaded:new Date().toISOString(),") + export default definePlugin({ name: "venfetch", description: "neofetch for vencord", authors: [Devs.nin0dev], - patches: [ - { - find: /.log\("[BUILD INFO]/, - replacement: [ - { - match: /Build Number: "\).concat\(("\d+")/, - replace: "Build Number: \").concat($self.setBuildNumber($1)" - }, - { - match: /Version Hash: \"\).concat\(("\w+")/, - replace: "Version Hash: \").concat($self.setVersionHash($1)" - } - ] - } - ], - setBuildNumber(buildNumber) { - return BUILD_NUMBER = buildNumber; - }, - setVersionHash(versionHash) { - return VERSION_HASH = versionHash; - }, commands: [ { name: "venfetch", @@ -136,23 +133,27 @@ export default definePlugin({ inputType: ApplicationCommandInputType.BUILT_IN, execute: (args: Argument[], ctx: CommandContext) => { const { username } = UserStore.getCurrentUser(); + const versions = getVersions(); const info: Record = { version: `${VERSION} ~ ${gitHash}${SettingsPlugin.additionalInfo} - ${Intl.DateTimeFormat(navigator.language, { dateStyle: "medium" }).format(BUILD_TIMESTAMP)}`, client: `${t(window.GLOBAL_ENV.RELEASE_CHANNEL)} ~ ${clientVersion()}`, - // TODO: fix this - // build: `${BUILD_NUMBER ?? "Unknown"} (${VERSION_HASH?.slice(0, 7) ?? 'unknown'})`, + 'Build Number': `${versions.buildNumber} ~ Hash: ${ versions.versionHash?.slice(0, 7) ?? 'unknown' }`, + + _: null, + // @ts-ignore platform: navigator.userAgentData?.platform ? `${navigator.userAgentData?.platform} (${navigator.platform})` : navigator.platform, plugins: getEnabledPlugins(), uptime: `${~~((Date.now() - uptime) / 1000)}s`, // TODO: pr to vencord real and add to vencordnative // memory: `${humanFileSize(VencordNative.memoryUsage().heapUsed)} / ${humanFileSize(VencordNative.memoryUsage().heapTotal)}`, - _: null, + + __: null, donor: getDonorStatus() ? "yes" : "no", contributor: getContribStatus() ? "yes" : "no", - __: null, + ___: null, __COLOR_TEST__: "███████████████████████████" From 808dfc82473d12a81f514e9a28db7a3e4f401b7a Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Mon, 28 Oct 2024 04:48:42 +1300 Subject: [PATCH 4/8] fixes and plugin totals --- index.ts | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/index.ts b/index.ts index 9d34bcf..05facd1 100644 --- a/index.ts +++ b/index.ts @@ -8,12 +8,13 @@ import { ApplicationCommandInputType, Argument, CommandContext } from "@api/Comm import { gitHash } from "@shared/vencordUserAgent"; import { Devs } from "@utils/constants"; import { sendMessage } from "@utils/discord"; -import definePlugin from "@utils/types"; +import definePlugin, { Plugin } from "@utils/types"; import { GuildMemberStore, UserStore } from "@webpack/common"; -import { PluginMeta } from "~plugins"; +import plugins, { PluginMeta } from "~plugins"; import SettingsPlugin from "../../plugins/_core/settings"; +import { isPluginDev } from "@utils/misc"; const clientVersion = () => { const version = IS_DISCORD_DESKTOP ? DiscordNative.app.getVersion() : IS_VESKTOP ? VesktopNative.app.getVersion() : null; @@ -22,7 +23,6 @@ const clientVersion = () => { return `${name}${version ? ` v${version}` : ''}`; }; -const uptime = Date.now(); const lines = `\ VV VV @@ -62,21 +62,32 @@ VV VV // CCCCCCC ███████████████████████████ // ```; +const isApiPlugin = (plugin: Plugin) => plugin.name.endsWith("API") || plugin.required; + function getEnabledPlugins() { let counter = 0; + let total = 0; let userpluginsCount = 0; + let totalUserplugins = 0; - Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => { - if (value.started) if (PluginMeta[value.name].userPlugin) userpluginsCount++; else counter++; + Object.values(plugins).filter((plugin) => !isApiPlugin(plugin)).forEach((plugin) => { + if (PluginMeta[plugin.name].userPlugin) { + if (plugin.started) userpluginsCount++; + totalUserplugins++; + } else { + if (plugin.started) counter++; + total++; + }; }); - return `${counter} (official)` + (userpluginsCount ? `, ${userpluginsCount} (userplugins)` : ""); + return `${counter}/${total} (official)` + (totalUserplugins ? `, ${userpluginsCount}/${totalUserplugins} (userplugins)` : ""); } function getDonorStatus() { return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532"); } function getContribStatus() { - return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1026534353167208489"); + const userId = UserStore.getCurrentUser().id; + return isPluginDev(userId) || GuildMemberStore.getMember("1015060230222131221", userId).roles.includes("1026534353167208489"); } function humanFileSize(bytes, si = false, dp = 1) { @@ -118,7 +129,7 @@ export default definePlugin({ // @ts-ignore platform: navigator.userAgentData?.platform ?? navigator.platform, plugins: getEnabledPlugins(), - uptime: `${~~((Date.now() - uptime) / 1000)}s`, + uptime: `${~~((Date.now() - window.GLOBAL_ENV.HTML_TIMESTAMP) / 1000)}s`, // TODO: pr to vencord real and add to vencordnative // memory: `${humanFileSize(VencordNative.memoryUsage().heapUsed)} / ${humanFileSize(VencordNative.memoryUsage().heapTotal)}`, _: null, @@ -162,4 +173,4 @@ export default definePlugin({ ] }); -const t = (e: string) => e[0].toUpperCase() + e.slice(1); +const t = (e: string) => e.length > 0 ? e[0].toUpperCase() + e.slice(1) : ""; From cb617a8ed7701f43480491abbb57129281a30b00 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 19 Jan 2025 16:53:44 +0000 Subject: [PATCH 5/8] add common issues --- index.ts | 69 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/index.ts b/index.ts index a620f56..bfdc55a 100644 --- a/index.ts +++ b/index.ts @@ -11,11 +11,12 @@ import { sendMessage } from "@utils/discord"; import definePlugin, { Plugin } from "@utils/types"; import { GuildMemberStore, UserStore } from "@webpack/common"; -import plugins, { PluginMeta } from "~plugins"; +import { PluginMeta } from "~plugins"; -import SettingsPlugin from "../../plugins/_core/settings"; -import { isPluginDev } from "@utils/misc"; +import { isPluginDev, tryOrElse } from "@utils/misc"; import { findByCodeLazy } from "@webpack"; +import { getUserSettingLazy } from "../../api/UserSettings.js"; +import SettingsPlugin from "../../plugins/_core/settings"; const clientVersion = () => { const version = IS_DISCORD_DESKTOP ? DiscordNative.app.getVersion() : IS_VESKTOP ? VesktopNative.app.getVersion() : null; @@ -26,28 +27,30 @@ const clientVersion = () => { }; const lines = `\ -VV VV - VV VV - VV VV - VV VV - VVV - CCCCCCC - CC - CC - CC - CCCCCCC\ +\n\ +\tVV VV +\t VV VV +\t VV VV +\t VV VV +\t VVV +\t CCCCCCC +\t CC +\t CC +\t CC +\t CCCCCCC\ `.split("\n"); const sanitised = `\ -VV VV - VV VV - VV VV - VV VV - VVV - CCCCCCC - CC - CC - CC - CCCCCCC\ +\n\ +\tVV VV +\t VV VV +\t VV VV +\t VV VV +\t VVV +\t CCCCCCC +\t CC +\t CC +\t CC +\t CCCCCCC\ `.split("\n"); // ```ansi @@ -120,6 +123,8 @@ function humanFileSize(bytes, si = false, dp = 1) { } const getVersions = findByCodeLazy("logsUploaded:new Date().toISOString(),"); +const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!; + export default definePlugin({ name: "venfetch", @@ -131,12 +136,20 @@ export default definePlugin({ description: "neofetch for vencord", inputType: ApplicationCommandInputType.BUILT_IN, execute: (args: Argument[], ctx: CommandContext) => { + const commonIssues = { + "NoRPC": Vencord.Plugins.isPluginEnabled("NoRPC"), + "disabled activities": tryOrElse(() => !ShowCurrentGame.getSetting(), false), + "outdated": BUILD_TIMESTAMP < Date.now() - 12096e5, + "likes java": ['287555395151593473', '886685857560539176', "728342296696979526"].includes(UserStore.getCurrentUser().id), + }; + const { username } = UserStore.getCurrentUser(); const versions = getVersions(); const info: Record = { - version: `${VERSION} ~ ${gitHash}${SettingsPlugin.additionalInfo} - ${Intl.DateTimeFormat(navigator.language, { dateStyle: "medium" }).format(BUILD_TIMESTAMP)}`, + version: `${VERSION} ~ ${gitHash}${SettingsPlugin.additionalInfo} - ${Intl.DateTimeFormat(navigator.language, { dateStyle: "medium" }).format(BUILD_TIMESTAMP)}${!IS_STANDALONE ? ` ~ dev` : ""}`, client: `${t(window.GLOBAL_ENV.RELEASE_CHANNEL)} ~ ${clientVersion()}`, 'Build Number': `${versions.buildNumber} ~ Hash: ${versions.versionHash?.slice(0, 7) ?? 'unknown'}`, + issues: Object.entries(commonIssues).filter(([_, value]) => value).map(([key]) => key).join(", ") || '', _: null, @@ -144,7 +157,7 @@ export default definePlugin({ platform: navigator.userAgentData?.platform ? `${navigator.userAgentData?.platform} (${navigator.platform})` : navigator.platform, plugins: getEnabledPlugins(), uptime: `${~~((Date.now() - window.GLOBAL_ENV.HTML_TIMESTAMP) / 1000)}s`, - // TODO: pr to vencord real and add to vencordnative + // TODO: add to native.ts // memory: `${humanFileSize(VencordNative.memoryUsage().heapUsed)} / ${humanFileSize(VencordNative.memoryUsage().heapTotal)}`, __: null, @@ -159,7 +172,7 @@ export default definePlugin({ // electron web context, want to get total memory usage }; - const computed: [string, string | null][] = Object.entries(info).map(([key, value]) => [key, value]); + const computed: [string, string | null][] = Object.entries(info).filter(([key, value]) => value === null || value!.length).map(([key, value]) => [key, value]); let str = ""; @@ -171,10 +184,10 @@ export default definePlugin({ if (lines[i]) { str += `${lines[i]}`; - if (line && line[1] !== null && line[0] !== "__COLOR_TEST__") str += `${" ".repeat(25 - sanitised[i].length)}${t(line[0])}: ${line[1]}\n`; + if (line && line[1] !== null && line[0] !== "__COLOR_TEST__") str += `${" ".repeat(22 - sanitised[i].length)}${t(line[0])}: ${line[1]}\n`; else if (line[0] === "__COLOR_TEST__") str += line[0] + "\n"; else str += "\n"; } else { - if (line && line[1] !== null && line[0] !== "__COLOR_TEST__") str += `${" ".repeat(25)}${t(line[0])}: ${line[1]}\n`; + if (line && line[1] !== null && line[0] !== "__COLOR_TEST__") str += `\t${" ".repeat(22)}${t(line[0])}: ${line[1]}\n`; else if (line[0] === "__COLOR_TEST__") str += `${" ".repeat(25)}${line[1]}\n`; else str += "\n"; } } From 788c01e81a0d2a688be61e2863f2d2eb88c594af Mon Sep 17 00:00:00 2001 From: splatter Date: Sat, 1 Feb 2025 15:04:42 +0000 Subject: [PATCH 6/8] add memory Signed-off-by: splatter --- index.ts | 54 +++++++++++++++++++++++++++++------------------------- native.ts | 8 ++++++++ 2 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 native.ts diff --git a/index.ts b/index.ts index bfdc55a..d58f73b 100644 --- a/index.ts +++ b/index.ts @@ -8,7 +8,7 @@ import { ApplicationCommandInputType, Argument, CommandContext } from "@api/Comm import { gitHash } from "@shared/vencordUserAgent"; import { Devs } from "@utils/constants"; import { sendMessage } from "@utils/discord"; -import definePlugin, { Plugin } from "@utils/types"; +import definePlugin, { Plugin, PluginNative } from "@utils/types"; import { GuildMemberStore, UserStore } from "@webpack/common"; import { PluginMeta } from "~plugins"; @@ -18,6 +18,8 @@ import { findByCodeLazy } from "@webpack"; import { getUserSettingLazy } from "../../api/UserSettings.js"; import SettingsPlugin from "../../plugins/_core/settings"; +const Native = VencordNative.pluginHelpers.venfetch as PluginNative; + const clientVersion = () => { const version = IS_DISCORD_DESKTOP ? DiscordNative.app.getVersion() : IS_VESKTOP ? VesktopNative.app.getVersion() : null; // @ts-ignore @@ -100,27 +102,7 @@ function getContribStatus() { return isPluginDev(userId) || GuildMemberStore.getMember("1015060230222131221", userId).roles.includes("1026534353167208489"); } -function humanFileSize(bytes, si = false, dp = 1) { - const thresh = si ? 1000 : 1024; - if (Math.abs(bytes) < thresh) { - return bytes + " B"; - } - - const units = si - ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] - : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]; - let u = -1; - const r = 10 ** dp; - - do { - bytes /= thresh; - ++u; - } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1); - - - return bytes.toFixed(dp) + " " + units[u]; -} const getVersions = findByCodeLazy("logsUploaded:new Date().toISOString(),"); const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!; @@ -135,7 +117,7 @@ export default definePlugin({ name: "venfetch", description: "neofetch for vencord", inputType: ApplicationCommandInputType.BUILT_IN, - execute: (args: Argument[], ctx: CommandContext) => { + execute: async (args: Argument[], ctx: CommandContext) => { const commonIssues = { "NoRPC": Vencord.Plugins.isPluginEnabled("NoRPC"), "disabled activities": tryOrElse(() => !ShowCurrentGame.getSetting(), false), @@ -143,6 +125,8 @@ export default definePlugin({ "likes java": ['287555395151593473', '886685857560539176', "728342296696979526"].includes(UserStore.getCurrentUser().id), }; + const memory = await Native?.getMemory(); + const { username } = UserStore.getCurrentUser(); const versions = getVersions(); const info: Record = { @@ -157,8 +141,7 @@ export default definePlugin({ platform: navigator.userAgentData?.platform ? `${navigator.userAgentData?.platform} (${navigator.platform})` : navigator.platform, plugins: getEnabledPlugins(), uptime: `${~~((Date.now() - window.GLOBAL_ENV.HTML_TIMESTAMP) / 1000)}s`, - // TODO: add to native.ts - // memory: `${humanFileSize(VencordNative.memoryUsage().heapUsed)} / ${humanFileSize(VencordNative.memoryUsage().heapTotal)}`, + memory: memory ? `${humanFileSize(memory.heapUsed)} / ${humanFileSize(memory.heapTotal)}` : '', __: null, @@ -188,7 +171,7 @@ export default definePlugin({ else if (line[0] === "__COLOR_TEST__") str += line[0] + "\n"; else str += "\n"; } else { if (line && line[1] !== null && line[0] !== "__COLOR_TEST__") str += `\t${" ".repeat(22)}${t(line[0])}: ${line[1]}\n`; - else if (line[0] === "__COLOR_TEST__") str += `${" ".repeat(25)}${line[1]}\n`; else str += "\n"; + else if (line[0] === "__COLOR_TEST__") str += `${" ".repeat(22)}${line[1]}\n`; else str += "\n"; } } @@ -202,3 +185,24 @@ export default definePlugin({ }); const t = (e: string) => e.length > 0 ? e[0].toUpperCase() + e.slice(1) : ""; +function humanFileSize(bytes, si = false, dp = 1) { + const thresh = si ? 1000 : 1024; + + if (Math.abs(bytes) < thresh) { + return bytes + " B"; + } + + const units = si + ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] + : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]; + let u = -1; + const r = 10 ** dp; + + do { + bytes /= thresh; + ++u; + } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1); + + + return bytes.toFixed(dp) + " " + units[u]; +} diff --git a/native.ts b/native.ts new file mode 100644 index 0000000..7095bc2 --- /dev/null +++ b/native.ts @@ -0,0 +1,8 @@ + +export function getMemory() { + const memory = process.memoryUsage(); + return { + heapUsed: memory.heapUsed, + heapTotal: memory.heapTotal + }; +} From c4d7b98e72ce70ea7ad0c930096b9a4a60a94fe0 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 2 Feb 2025 02:04:33 +0000 Subject: [PATCH 7/8] refactor rendering code Signed-off-by: splatter --- index.ts | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/index.ts b/index.ts index d58f73b..1b375a8 100644 --- a/index.ts +++ b/index.ts @@ -28,7 +28,10 @@ const clientVersion = () => { return `${name}${version ? ` v${version}` : ''}`; }; -const lines = `\ +const COLOR_TEST = '███████████████████████████'; + + +const LOGO_WITH_ANSI = `\ \n\ \tVV VV \t VV VV @@ -41,7 +44,7 @@ const lines = `\ \t CC \t CCCCCCC\ `.split("\n"); -const sanitised = `\ +const LOGO_NO_ANSI = `\ \n\ \tVV VV \t VV VV @@ -122,7 +125,6 @@ export default definePlugin({ "NoRPC": Vencord.Plugins.isPluginEnabled("NoRPC"), "disabled activities": tryOrElse(() => !ShowCurrentGame.getSetting(), false), "outdated": BUILD_TIMESTAMP < Date.now() - 12096e5, - "likes java": ['287555395151593473', '886685857560539176', "728342296696979526"].includes(UserStore.getCurrentUser().id), }; const memory = await Native?.getMemory(); @@ -150,31 +152,38 @@ export default definePlugin({ ___: null, - __COLOR_TEST__: "███████████████████████████" - // electron web context, want to get total memory usage }; const computed: [string, string | null][] = Object.entries(info).filter(([key, value]) => value === null || value!.length).map(([key, value]) => [key, value]); let str = ""; + const MAGIC_NUMBER = 25; - str += `${lines[0]}${" ".repeat(25 - lines[0].length)}${username}\n`; + str += `${LOGO_WITH_ANSI[0]}${" ".repeat(MAGIC_NUMBER - LOGO_NO_ANSI[0].length)}${username}\n`; for (let i = 1; i < computed.length + 1; i++) { + const logoLine = LOGO_WITH_ANSI[i]; const line = computed[i - 1]; - if (lines[i]) { - str += `${lines[i]}`; - - if (line && line[1] !== null && line[0] !== "__COLOR_TEST__") str += `${" ".repeat(22 - sanitised[i].length)}${t(line[0])}: ${line[1]}\n`; - else if (line[0] === "__COLOR_TEST__") str += line[0] + "\n"; else str += "\n"; + if (logoLine) { + str += logoLine; + str += " ".repeat(MAGIC_NUMBER - 3 - LOGO_NO_ANSI[i].length); } else { - if (line && line[1] !== null && line[0] !== "__COLOR_TEST__") str += `\t${" ".repeat(22)}${t(line[0])}: ${line[1]}\n`; - else if (line[0] === "__COLOR_TEST__") str += `${" ".repeat(22)}${line[1]}\n`; else str += "\n"; + str += " ".repeat(MAGIC_NUMBER); } + + const [key, value] = line; + + if (!key.startsWith("_") && value) { + str += `${key[0].toUpperCase()}${key.slice(1)}: ${value}`; + } + + str += '\n'; } + str += `${" ".repeat(MAGIC_NUMBER)}${COLOR_TEST}\n`; + sendMessage(ctx.channel.id, { content: `\`\`\`ansi\n${str}\n\`\`\`` }); From b8f77887ac8a78e7522c2cf83da592f9fe792a78 Mon Sep 17 00:00:00 2001 From: splatter Date: Mon, 24 Feb 2025 01:06:27 +0000 Subject: [PATCH 8/8] fix edge case with plugin without a name Signed-off-by: splatter --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 1b375a8..e13cf38 100644 --- a/index.ts +++ b/index.ts @@ -71,7 +71,7 @@ const LOGO_NO_ANSI = `\ // CCCCCCC ███████████████████████████ // ```; -const isApiPlugin = (plugin: Plugin) => plugin.name.endsWith("API") || plugin.required; +const isApiPlugin = (plugin: Plugin) => plugin.name?.endsWith("API") || plugin.required; function getEnabledPlugins() { const counters = {