From 89ee3fba97b7d21063065f0393e1c058936dd224 Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Sun, 27 Oct 2024 11:56:54 -0400 Subject: [PATCH 1/3] fixes and plugin totals (#3) excludes API plugins like /vencord-plugins contributor shows if you arent in the vencord server remove duplicate Date.now() call just use the one provided by Discord itself (might be slightly different? does it matter?) Reviewed-on: https://git.nin0.dev///userplugins/venfetch/pulls/3 Co-authored-by: Sqaaakoi Co-committed-by: Sqaaakoi --- 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 2ddf4753c149b76eb395e69106a5ae3c4b9a54a3 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 27 Oct 2024 15:57:50 +0000 Subject: [PATCH 2/3] its shiggy season --- index.ts | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 05facd1..2c6da77 100644 --- a/index.ts +++ b/index.ts @@ -13,8 +13,8 @@ import { GuildMemberStore, UserStore } from "@webpack/common"; import plugins, { PluginMeta } from "~plugins"; -import SettingsPlugin from "../../plugins/_core/settings"; import { isPluginDev } from "@utils/misc"; +import SettingsPlugin from "../../plugins/_core/settings"; const clientVersion = () => { const version = IS_DISCORD_DESKTOP ? DiscordNative.app.getVersion() : IS_VESKTOP ? VesktopNative.app.getVersion() : null; @@ -112,10 +112,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", @@ -126,8 +150,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() - window.GLOBAL_ENV.HTML_TIMESTAMP) / 1000)}s`, // TODO: pr to vencord real and add to vencordnative @@ -135,7 +161,7 @@ export default definePlugin({ _: null, donor: getDonorStatus() ? "yes" : "no", - contributor: getContribStatus() ? "yes" : null, + contributor: getContribStatus() ? "yes" : "no", __: null, From 675cabb3102b5c95cb852012ef3540281d30de8e Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 27 Oct 2024 15:59:15 +0000 Subject: [PATCH 3/3] add spaces --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 2c6da77..51728bc 100644 --- a/index.ts +++ b/index.ts @@ -80,7 +80,7 @@ function getEnabledPlugins() { }; }); - return `${counter}/${total} (official)` + (totalUserplugins ? `, ${userpluginsCount}/${totalUserplugins} (userplugins)` : ""); + return `${counter} / ${total} (official)` + (totalUserplugins ? `, ${userpluginsCount} / ${totalUserplugins} (userplugins)` : ""); } function getDonorStatus() { return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532");