111 lines
4.7 KiB
TypeScript
111 lines
4.7 KiB
TypeScript
/*
|
||
* Vencord, a Discord client mod
|
||
* Copyright (c) 2024 Vendicated and contributors
|
||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||
*/
|
||
|
||
import { ApplicationCommandInputType, Argument, CommandContext } from "@api/Commands";
|
||
import { gitHash } from "@shared/vencordUserAgent";
|
||
import { Devs } from "@utils/constants";
|
||
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 = (() => {
|
||
if (IS_DISCORD_DESKTOP) return `Discord Desktop v${DiscordNative.app.getVersion()}`;
|
||
if (IS_VESKTOP) return `Vesktop v${VesktopNative.app.getVersion()}`;
|
||
if ("legcord" in window) return `Legcord v${window.legcord.version}`;
|
||
|
||
// @ts-expect-error
|
||
const name = typeof unsafeWindow !== "undefined" ? "UserScript" : "Web";
|
||
return `${name} (${navigator.userAgent})`;
|
||
})();
|
||
const launchTime = Date.now();
|
||
|
||
const line1 = "```ansi";
|
||
// Placeholders: %username%
|
||
const line2 = "VV VV [1;2m[4;2m[0m[0m[4;2m[1;2m%username%[0m[0m";
|
||
const line3 = " VV VV ---------------";
|
||
// Placeholders: %ver%
|
||
const line4 = " VV VV [2;35m[0m[2;35mVersion: [0m[0m%ver%[0m[2;35m[0m";
|
||
// Placeholders: %client%
|
||
const line5 = " VV VV [2;35m[0m[2;35mClient: [0m[0m%client%[0m[2;35m[0m";
|
||
// Placeholders: %platform%
|
||
const line6 = " VVV [2;35m[0m[2;35mPlatform: [0m[0m%platform%[0m[2;35m[0m";
|
||
// Placeholders: %pluginCount%
|
||
const line7 = " [2;35mCCCCCCC [2;35m[0m[2;35mPlugin Count: [0m[0m%pluginCount%[0m[2;35m[0m";
|
||
// Placeholders: %uptime%
|
||
const line8 = " [2;35mCC [2;35m[0m[2;35mUptime: [0m[0m%uptime%[0m[2;35m[0m";
|
||
// Placeholders: %donorStatus%
|
||
const line9 = " [2;35mCC [2;35m[0m[2;35mDonor: [0m[0m%donorStatus%[0m[2;35m[0m";
|
||
const line10 = " [2;35mCC";
|
||
const line11 = " [2;35mCCCCCCC[0m [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";
|
||
const line12 = "```";
|
||
|
||
function getEnabledPlugins() {
|
||
let counter = 0;
|
||
Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => {
|
||
if (value.started) counter++;
|
||
});
|
||
return counter.toString();
|
||
}
|
||
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],
|
||
commands: [
|
||
{
|
||
name: "venfetch",
|
||
description: "neofetch for vencord",
|
||
inputType: ApplicationCommandInputType.BUILT_IN,
|
||
execute: (args: Argument[], ctx: CommandContext) => {
|
||
const { username } = UserStore.getCurrentUser();
|
||
const info = {
|
||
Vencord:
|
||
`v${VERSION} • ${gitHash}` +
|
||
`${SettingsPlugin.additionalInfo} - ${Intl.DateTimeFormat("en-GB", { dateStyle: "medium" }).format(BUILD_TIMESTAMP)}`,
|
||
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%", `${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}`
|
||
});
|
||
return;
|
||
}
|
||
}
|
||
]
|
||
});
|