fixes and plugin totals #3

Merged
duke merged 1 commit from Sqaaakoi-VencordUserPlugins/venfetch-fork:guh into main 2024-10-27 11:56:55 -04:00

View file

@ -8,12 +8,13 @@ import { ApplicationCommandInputType, Argument, CommandContext } from "@api/Comm
import { gitHash } from "@shared/vencordUserAgent"; import { gitHash } from "@shared/vencordUserAgent";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { sendMessage } from "@utils/discord"; import { sendMessage } from "@utils/discord";
import definePlugin from "@utils/types"; import definePlugin, { Plugin } from "@utils/types";
import { GuildMemberStore, UserStore } from "@webpack/common"; import { GuildMemberStore, UserStore } from "@webpack/common";
import { PluginMeta } from "~plugins"; import plugins, { PluginMeta } from "~plugins";
import SettingsPlugin from "../../plugins/_core/settings"; import SettingsPlugin from "../../plugins/_core/settings";
import { isPluginDev } from "@utils/misc";
const clientVersion = () => { const clientVersion = () => {
const version = IS_DISCORD_DESKTOP ? DiscordNative.app.getVersion() : IS_VESKTOP ? VesktopNative.app.getVersion() : null; 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}` : ''}`; return `${name}${version ? ` v${version}` : ''}`;
}; };
const uptime = Date.now();
const lines = `\ const lines = `\
VV VV VV VV
@ -62,21 +62,32 @@ VV VV
// CCCCCCC ███████████████████████████ // CCCCCCC ███████████████████████████
// ```; // ```;
const isApiPlugin = (plugin: Plugin) => plugin.name.endsWith("API") || plugin.required;
function getEnabledPlugins() { function getEnabledPlugins() {
let counter = 0; let counter = 0;
let total = 0;
let userpluginsCount = 0; let userpluginsCount = 0;
let totalUserplugins = 0;
Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => { Object.values(plugins).filter((plugin) => !isApiPlugin(plugin)).forEach((plugin) => {
if (value.started) if (PluginMeta[value.name].userPlugin) userpluginsCount++; else counter++; 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() { function getDonorStatus() {
return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532"); return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532");
} }
function getContribStatus() { 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) { function humanFileSize(bytes, si = false, dp = 1) {
@ -118,7 +129,7 @@ export default definePlugin({
// @ts-ignore // @ts-ignore
platform: navigator.userAgentData?.platform ?? navigator.platform, platform: navigator.userAgentData?.platform ?? navigator.platform,
plugins: getEnabledPlugins(), 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 // TODO: pr to vencord real and add to vencordnative
// memory: `${humanFileSize(VencordNative.memoryUsage().heapUsed)} / ${humanFileSize(VencordNative.memoryUsage().heapTotal)}`, // memory: `${humanFileSize(VencordNative.memoryUsage().heapUsed)} / ${humanFileSize(VencordNative.memoryUsage().heapTotal)}`,
_: null, _: 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) : "";