add build number
This commit is contained in:
parent
59c84ebb5d
commit
5c867c19f9
1 changed files with 30 additions and 29 deletions
59
index.ts
59
index.ts
|
@ -14,6 +14,7 @@ import { GuildMemberStore, UserStore } from "@webpack/common";
|
||||||
import { PluginMeta } from "~plugins";
|
import { PluginMeta } from "~plugins";
|
||||||
|
|
||||||
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;
|
||||||
|
@ -63,14 +64,28 @@ VV VV
|
||||||
// ```;
|
// ```;
|
||||||
|
|
||||||
function getEnabledPlugins() {
|
function getEnabledPlugins() {
|
||||||
let counter = 0;
|
const counters = {
|
||||||
let userpluginsCount = 0;
|
official: {
|
||||||
|
enabled: 0,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
enabled: 0,
|
||||||
|
total: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => {
|
Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => {
|
||||||
if (value.started) if (PluginMeta[value.name]?.userPlugin) userpluginsCount++; else counter++;
|
if (PluginMeta[value.name]?.userPlugin) {
|
||||||
|
if (value.started) counters.user.enabled++;
|
||||||
|
counters.user.total++;
|
||||||
|
} else {
|
||||||
|
if (value.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() {
|
function getDonorStatus() {
|
||||||
return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532");
|
return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532");
|
||||||
|
@ -104,31 +119,13 @@ 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",
|
||||||
|
@ -136,23 +133,27 @@ 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()}`,
|
||||||
// TODO: fix this
|
'Build Number': `${versions.buildNumber} ~ Hash: ${ versions.versionHash?.slice(0, 7) ?? 'unknown' }`,
|
||||||
// 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() - uptime) / 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__: "[2;40m[2;30m███[0m[2;40m[0m[2;31m[0m[2;30m███[0m[2;31m███[0m[2;32m███[0m[2;33m███[0m[2;34m███[0m[2;35m███[0m[2;36m███[0m[2;37m███[0m"
|
__COLOR_TEST__: "[2;40m[2;30m███[0m[2;40m[0m[2;31m[0m[2;30m███[0m[2;31m███[0m[2;32m███[0m[2;33m███[0m[2;34m███[0m[2;35m███[0m[2;36m███[0m[2;37m███[0m"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue