diff --git a/index.ts b/index.ts index 1194eac..8d3ada5 100644 --- a/index.ts +++ b/index.ts @@ -11,6 +11,8 @@ import { sendMessage } from "@utils/discord"; import definePlugin from "@utils/types"; import { GuildMemberStore, UserStore } from "@webpack/common"; +import plugins, { PluginMeta } from "~plugins"; + import SettingsPlugin from "../../plugins/_core/settings"; const client = (() => { @@ -22,7 +24,7 @@ const client = (() => { const name = typeof unsafeWindow !== "undefined" ? "UserScript" : "Web"; return `${name} (${navigator.userAgent})`; })(); -let uptime = 0; +const launchTime = Date.now(); const line1 = "```ansi"; // Placeholders: %username% @@ -54,16 +56,25 @@ function getEnabledPlugins() { function getDonorStatus() { return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532"); } +function getPluginCount() { + const isApiPlugin = (plugin: string) => plugin.endsWith("API") || plugins[plugin].required; + + const enabledPlugins = Object.keys(plugins) + .filter(p => Vencord.Plugins.isPluginEnabled(p) && !isApiPlugin(p)); + + const enabledStockPlugins = enabledPlugins.filter(p => !PluginMeta[p].userPlugin); + const enabledUserPlugins = enabledPlugins.filter(p => PluginMeta[p].userPlugin); + + return { + stock: enabledStockPlugins.length, + user: enabledUserPlugins.length + }; +} export default definePlugin({ name: "venfetch", description: "neofetch for vencord", authors: [Devs.nin0dev], - start() { - setInterval(() => { - uptime++; - }, 1000); - }, commands: [ { name: "venfetch", @@ -78,15 +89,16 @@ export default definePlugin({ Client: `${window.GLOBAL_ENV.RELEASE_CHANNEL} ~ ${client}`, Platform: window.navigator.platform }; + const pluggers = getPluginCount(); sendMessage(ctx.channel.id, { content: `${line1} ${line2.replace("%username%", username)} ${line3}\n${line4.replace("%ver%", info.Vencord)} ${line5.replace("%client%", info.Client)} ${line6.replace("%platform%", info.Platform)} -${line7.replace("%pluginCount%", getEnabledPlugins())} -${line8.replace("%uptime%", `${uptime}s`)} -${line9.replace("%donorStatus%", getDonorStatus() ? "yes" : "no")} +${line7.replace("%pluginCount%", `${pluggers.stock} official, ${pluggers.user} userplugins`)} +${line8.replace("%uptime%", `${Math.floor((Date.now() - launchTime) / 1000)}s`)} +${line9.replace("%donorStatus%", getDonorStatus() ? "yop" : "nop")} ${line10} ${line11} ${line12}`