Compare commits

..

3 commits

Author SHA1 Message Date
675cabb310 add spaces 2024-10-27 15:59:15 +00:00
2ddf4753c1 its shiggy season 2024-10-27 15:57:50 +00:00
89ee3fba97 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 <sqaaakoi-git@sqaaakoi.xyz>
Co-committed-by: Sqaaakoi <sqaaakoi-git@sqaaakoi.xyz>
2024-10-27 11:56:54 -04:00

View file

@ -8,13 +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 { isPluginDev } from "@utils/misc";
import SettingsPlugin from "../../plugins/_core/settings"; import SettingsPlugin from "../../plugins/_core/settings";
import { findByCodeLazy } from "../../webpack/webpack.js";
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;
@ -23,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
@ -63,35 +62,32 @@ VV VV
// CCCCCCC ███████████████████████████ // CCCCCCC ███████████████████████████
// ```; // ```;
function getEnabledPlugins() { const isApiPlugin = (plugin: Plugin) => plugin.name.endsWith("API") || plugin.required;
const counters = {
official: {
enabled: 0,
total: 0
},
user: {
enabled: 0,
total: 0
}
}
Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => { function getEnabledPlugins() {
if (PluginMeta[value.name]?.userPlugin) { let counter = 0;
if (value.started) counters.user.enabled++; let total = 0;
counters.user.total++; let userpluginsCount = 0;
let totalUserplugins = 0;
Object.values(plugins).filter((plugin) => !isApiPlugin(plugin)).forEach((plugin) => {
if (PluginMeta[plugin.name].userPlugin) {
if (plugin.started) userpluginsCount++;
totalUserplugins++;
} else { } else {
if (value.started) counters.official.enabled++; if (plugin.started) counter++;
counters.official.total++; total++;
} };
}); });
return `${counters.official.enabled} / ${counters.official.total} (official)` + (counters.user.total ? `, ${counters.user.enabled} / ${counters.user.total} (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) {
@ -119,13 +115,31 @@ function humanFileSize(bytes, si = false, dp = 1) {
let BUILD_NUMBER; let BUILD_NUMBER;
let VERSION_HASH; let VERSION_HASH;
const getVersions = findByCodeLazy("logsUploaded:new Date().toISOString(),")
export default definePlugin({ export default definePlugin({
name: "venfetch", name: "venfetch",
description: "neofetch for vencord", description: "neofetch for vencord",
authors: [Devs.nin0dev], 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: [ commands: [
{ {
name: "venfetch", name: "venfetch",
@ -133,27 +147,23 @@ export default definePlugin({
inputType: ApplicationCommandInputType.BUILT_IN, inputType: ApplicationCommandInputType.BUILT_IN,
execute: (args: Argument[], ctx: CommandContext) => { execute: (args: Argument[], ctx: CommandContext) => {
const { username } = UserStore.getCurrentUser(); const { username } = UserStore.getCurrentUser();
const versions = getVersions();
const info: Record<string, string | null> = { const info: Record<string, string | null> = {
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)}`,
client: `${t(window.GLOBAL_ENV.RELEASE_CHANNEL)} ~ ${clientVersion()}`, client: `${t(window.GLOBAL_ENV.RELEASE_CHANNEL)} ~ ${clientVersion()}`,
'Build Number': `${versions.buildNumber} ~ Hash: ${ versions.versionHash?.slice(0, 7) ?? 'unknown' }`, // TODO: fix this
// build: `${BUILD_NUMBER ?? "Unknown"} (${VERSION_HASH?.slice(0, 7) ?? 'unknown'})`,
_: null,
// @ts-ignore // @ts-ignore
platform: navigator.userAgentData?.platform ? `${navigator.userAgentData?.platform} (${navigator.platform})` : navigator.platform, platform: navigator.userAgentData?.platform ? `${navigator.userAgentData?.platform} (${navigator.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,
donor: getDonorStatus() ? "yes" : "no", donor: getDonorStatus() ? "yes" : "no",
contributor: getContribStatus() ? "yes" : "no", contributor: getContribStatus() ? "yes" : "no",
___: null, __: null,
__COLOR_TEST__: "███████████████████████████" __COLOR_TEST__: "███████████████████████████"
@ -189,4 +199,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) : "";