diff --git a/src/equicordplugins/betterCommands/index.ts b/src/equicordplugins/betterCommands/index.ts new file mode 100644 index 000000000..bcb712355 --- /dev/null +++ b/src/equicordplugins/betterCommands/index.ts @@ -0,0 +1,36 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import { EquicordDevs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + +const settings = definePluginSettings({ + autoFillArguments: { + description: "Automatically fill command with all arguements instead of just required ones", + type: OptionType.BOOLEAN, + default: true, + } +}); + +export default definePlugin({ + name: "BetterCommands", + description: "Enhances the command system with miscellaneous improvements.", + authors: [EquicordDevs.thororen], + settings, + patches: [ + { + find: 'applicationCommand",', + predicate: () => settings.store.autoFillArguments, + replacement: [ + { + match: /!\i\.has.{0,10}&&\(\i\.required.{0,20}\]\)/, + replace: "true" + }, + ] + } + ] +}); diff --git a/src/equicordplugins/discordDevBanner/index.tsx b/src/equicordplugins/discordDevBanner/index.tsx index bb4125ce6..71c028dae 100644 --- a/src/equicordplugins/discordDevBanner/index.tsx +++ b/src/equicordplugins/discordDevBanner/index.tsx @@ -4,11 +4,49 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { migratePluginSettings } from "@api/Settings"; +import "./styles.css"; + import { EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; +import SettingsPlugin from "plugins/_core/settings"; + +import gitHash from "~git-hash"; + +import { settings } from "./settings"; + +function getVersion(): string { + if (IS_DEV) return "Dev"; + if (IS_WEB) return "Web"; + if (IS_VESKTOP) return `Vesktop v${VesktopNative.app.getVersion()}`; + if (IS_EQUIBOP) return `Equibop v${VesktopNative.app.getVersion()}`; + if (IS_STANDALONE) return "Standalone"; + return ""; +} + +export function transform(state?: string): string { + const { RELEASE_CHANNEL, BUILD_NUMBER, VERSION_HASH } = window.GLOBAL_ENV; + const buildChannel: string = names[RELEASE_CHANNEL] || RELEASE_CHANNEL.charAt(0).toUpperCase() + RELEASE_CHANNEL.slice(1); + const { chromiumVersion, electronVersion, } = SettingsPlugin; + const format = settings.store.format ?? "{buildChannel} {buildNumber} ({buildHash}) | {equicordName} {equicordVersion} ({equicordHash})"; + const baseFormat = state ?? format; + + const formatted = baseFormat + .replace(/{discordName}/g, "Discord") + .replace(/{buildChannel}/g, buildChannel) + .replace(/{buildNumber}/g, BUILD_NUMBER) + .replace(/{buildHash}/g, VERSION_HASH.slice(0, 9)) + .replace(/{equicordName}/g, "Equicord") + .replace(/{equicordVersion}/g, VERSION) + .replace(/{equicordHash}/g, gitHash) + .replace(/{equicordPlatform}/g, getVersion()) + .replace(/{electronName}/g, "Electron") + .replace(/{electronVersion}/g, electronVersion) + .replace(/{chromiumName}/g, "Chromium") + .replace(/{chromiumVersion}/g, chromiumVersion); + + return formatted; +} -// By default Discord only seems to only display 'Staging' so we map the names ourself const names: Record = { stable: "Stable", ptb: "PTB", @@ -16,14 +54,11 @@ const names: Record = { staging: "Staging" }; -// Useless for the normal User, but useful for me -migratePluginSettings("DiscordDevBanner", "devBanner"); - export default definePlugin({ name: "DiscordDevBanner", description: "Enables the Discord developer banner, in which displays the build-ID", - authors: [EquicordDevs.KrystalSkull], - + authors: [EquicordDevs.KrystalSkull, EquicordDevs.thororen], + settings, patches: [ { find: ".devBanner,", @@ -37,20 +72,11 @@ export default definePlugin({ replace: "$1null;" }, { - match: /\i\.\i\.format\(.{0,15},{buildNumber:(.{0,10})}\)/, - replace: "$self.transform($1)" + match: /\i\.\i\.format\(.{0,40}\)/, + replace: "$self.transform()" }, ] } ], - - transform(buildNumber: string) { - const releaseChannel: string = window.GLOBAL_ENV.RELEASE_CHANNEL; - - if (names[releaseChannel]) { - return `${names[releaseChannel]} ${buildNumber}`; - } else { - return `${releaseChannel.charAt(0).toUpperCase() + releaseChannel.slice(1)} ${buildNumber}`; - } - }, + transform, }); diff --git a/src/equicordplugins/discordDevBanner/settings.tsx b/src/equicordplugins/discordDevBanner/settings.tsx new file mode 100644 index 000000000..c14e3b4ff --- /dev/null +++ b/src/equicordplugins/discordDevBanner/settings.tsx @@ -0,0 +1,76 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import { OptionType } from "@utils/types"; +import { Forms, TextInput, useState } from "@webpack/common"; + +import { transform } from "."; + +export const settings = definePluginSettings({ + format: { + component: ({ setValue }) => FormatSetting(setValue), + type: OptionType.COMPONENT, + default: "{buildChannel} {buildNumber} ({buildHash}) | {equicordName} {equicordVersion} ({equicordHash})", + restartNeeded: true + } +}); + +function FormatSetting(setValue) { + const { format } = settings.store; + const [state, setState] = useState(format ?? "{buildChannel} {buildNumber} ({buildHash}) | {equicordName} {equicordVersion} ({equicordHash})"); + const [error, setError] = useState(null); + + const placeholderInfo = [ + "{discordName} - The word 'Discord'", + "{buildChannel} - Discord build channel (e.g. Stable)", + "{buildNumber} - Discord build number (e.g. 123456)", + "{buildHash} - Discord build hash (e.g. 123456789)", + "{equicordName} - The word 'Equicord'", + "{equicordVersion} - Version of Equicord (e.g. 1.0.0)", + "{equicordHash} - Equicord build hash (e.g. 123456789)", + "{equicordPlatform} - Platform Equicord is running on (e.g. Dev)", + "{electronName} - The word 'Electron'", + "{electronVersion} - Electron runtime version (e.g. 25.0.0)", + "{chromiumName} - The word 'Chromium'", + "{chromiumVersion} - Chromium engine version (e.g. 125.0.0.0)", + ]; + + function handleChange(newValue) { + if (!newValue.trim()) { + setError("Format cannot be empty."); + return; + } + setError(null); + setState(newValue); + setValue(newValue); + } + + const preview = transform(state); + + return ( + + Custom Format + + The format to transform the build number to. You can use the following placeholders: + {"\n\n"} + {placeholderInfo.join("\n")} + {"\n\n"} + + + Preview: {preview} + + + {error && ( + {error} + )} + + ); +} diff --git a/src/equicordplugins/discordDevBanner/styles.css b/src/equicordplugins/discordDevBanner/styles.css new file mode 100644 index 000000000..65628f5fd --- /dev/null +++ b/src/equicordplugins/discordDevBanner/styles.css @@ -0,0 +1,9 @@ +.vc-discord-dev-banner { + white-space: pre-wrap; + padding: 2px; +} + +.vc-discord-dev-banner-error { + margin-top: 8px; + color: var(--text-danger); +}