Compare commits

...

5 commits
main ... main

Author SHA1 Message Date
f095065fd5
fix merge conflict 2024-10-28 04:59:51 +13:00
808dfc8247
fixes and plugin totals 2024-10-28 04:48:42 +13:00
5c867c19f9 add build number 2024-10-27 15:46:08 +00:00
59c84ebb5d fix bug 2024-10-27 15:32:44 +00:00
585a1035c0 its shiggy season 2024-10-27 15:31:12 +00:00

View file

@ -8,12 +8,14 @@ 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";
import { findByCodeLazy } from "@webpack";
const clientVersion = () => {
const version = IS_DISCORD_DESKTOP ? DiscordNative.app.getVersion() : IS_VESKTOP ? VesktopNative.app.getVersion() : null;
@ -22,7 +24,6 @@ const clientVersion = () => {
return `${name}${version ? ` v${version}` : ''}`;
};
const uptime = Date.now();
const lines = `\
VV VV
@ -62,21 +63,38 @@ VV VV
// CCCCCCC ███████████████████████████
// ```;
function getEnabledPlugins() {
let counter = 0;
let userpluginsCount = 0;
const isApiPlugin = (plugin: Plugin) => plugin.name.endsWith("API") || plugin.required;
Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => {
if (value.started) if (PluginMeta[value.name].userPlugin) userpluginsCount++; else counter++;
function getEnabledPlugins() {
const counters = {
official: {
enabled: 0,
total: 0
},
user: {
enabled: 0,
total: 0
}
};
Object.values(Vencord.Plugins.plugins).filter((plugin) => !isApiPlugin(plugin)).forEach((plugin) => {
if (PluginMeta[plugin.name]?.userPlugin) {
if (plugin.started) counters.user.enabled++;
counters.user.total++;
} else {
if (plugin.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");
}
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) {
@ -101,6 +119,8 @@ function humanFileSize(bytes, si = false, dp = 1) {
return bytes.toFixed(dp) + " " + units[u];
}
const getVersions = findByCodeLazy("logsUploaded:new Date().toISOString(),");
export default definePlugin({
name: "venfetch",
description: "neofetch for vencord",
@ -112,22 +132,28 @@ export default definePlugin({
inputType: ApplicationCommandInputType.BUILT_IN,
execute: (args: Argument[], ctx: CommandContext) => {
const { username } = UserStore.getCurrentUser();
const versions = getVersions();
const info: Record<string, string | null> = {
version: `${VERSION} ~ ${gitHash}${SettingsPlugin.additionalInfo} - ${Intl.DateTimeFormat(navigator.language, { dateStyle: "medium" }).format(BUILD_TIMESTAMP)}`,
client: `${t(window.GLOBAL_ENV.RELEASE_CHANNEL)} ~ ${clientVersion()}`,
// @ts-ignore
platform: navigator.userAgentData?.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)}`,
'Build Number': `${versions.buildNumber} ~ Hash: ${versions.versionHash?.slice(0, 7) ?? 'unknown'}`,
_: null,
donor: getDonorStatus() ? "yes" : "no",
contributor: getContribStatus() ? "yes" : null,
// @ts-ignore
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
// memory: `${humanFileSize(VencordNative.memoryUsage().heapUsed)} / ${humanFileSize(VencordNative.memoryUsage().heapTotal)}`,
__: null,
donor: getDonorStatus() ? "yes" : "no",
contributor: getContribStatus() ? "yes" : "no",
___: null,
__COLOR_TEST__: "███████████████████████████"
// electron web context, want to get total memory usage
@ -162,4 +188,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) : "";