From 8ce7150ca376f6676a2dc21e96940dc554c28c90 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 29 Dec 2025 15:20:59 -0500 Subject: [PATCH] Misc: Move to proper imports --- .../settings/tabs/plugins/index.tsx | 2 +- .../settings/tabs/vencord/index.tsx | 3 +- src/equicordplugins/_api/userArea.ts | 4 +- .../betterQuickReact/index.tsx | 2 +- .../components/ChannelTabsContainer.tsx | 3 +- .../commandPalette/registry.tsx | 38 ++--- .../customTimestamps/index.tsx | 116 +--------------- .../customTimestamps/utils.tsx | 130 ++++++++++++++++++ .../equicordHelper/pluginButtons.tsx | 6 +- src/equicordplugins/equicordHelper/utils.tsx | 7 +- src/equicordplugins/loginWithQR/index.tsx | 3 +- .../loginWithQR/ui/modals/QrModal.tsx | 7 +- .../musicControls/youtubeMusic/YtmStore.ts | 3 +- src/equicordplugins/questify/index.tsx | 3 +- src/equicordplugins/stickerBlocker/index.tsx | 9 +- .../themeLibrary/components/ThemeCard.tsx | 2 +- .../themeLibrary/components/ThemeTab.tsx | 4 +- src/equicordplugins/wigglyText/index.tsx | 2 +- src/plugins/_core/supportHelper.tsx | 7 +- src/plugins/devCompanion.dev/util.tsx | 7 +- src/plugins/mentionAvatars/index.tsx | 4 +- src/plugins/messageLogger/index.tsx | 3 +- src/plugins/oneko/index.ts | 3 +- src/plugins/silentTyping/index.tsx | 3 +- 24 files changed, 197 insertions(+), 174 deletions(-) create mode 100644 src/equicordplugins/customTimestamps/utils.tsx diff --git a/src/components/settings/tabs/plugins/index.tsx b/src/components/settings/tabs/plugins/index.tsx index 00d0a9b9f..66a35a346 100644 --- a/src/components/settings/tabs/plugins/index.tsx +++ b/src/components/settings/tabs/plugins/index.tsx @@ -358,7 +358,7 @@ export default function PluginSettings() { const isApiPlugin = (plugin: string) => plugin.endsWith("API") || Plugins[plugin].required; const totalPlugins = Object.keys(Plugins).filter(p => !isApiPlugin(p)); - const enabledPlugins = Object.keys(Plugins).filter(p => Vencord.Plugins.isPluginEnabled(p) && !isApiPlugin(p)); + const enabledPlugins = Object.keys(Plugins).filter(p => isPluginEnabled(p) && !isApiPlugin(p)); const totalStockPlugins = totalPlugins.filter(p => !PluginMeta[p].userPlugin && !Plugins[p].hidden).length; const totalUserPlugins = totalPlugins.filter(p => PluginMeta[p].userPlugin).length; diff --git a/src/components/settings/tabs/vencord/index.tsx b/src/components/settings/tabs/vencord/index.tsx index 11047ca05..ee1d5eadf 100644 --- a/src/components/settings/tabs/vencord/index.tsx +++ b/src/components/settings/tabs/vencord/index.tsx @@ -7,6 +7,7 @@ import "./VencordTab.css"; import { openNotificationLogModal } from "@api/Notifications/notificationLog"; +import { plugins } from "@api/PluginManager"; import { useSettings } from "@api/Settings"; import { Button } from "@components/Button"; import { Divider } from "@components/Divider"; @@ -228,7 +229,7 @@ function EquicordSettings() { You can customize where this settings section appears in Discord's settings menu by configuring the{" "} openPluginModal(Vencord.Plugins.plugins.Settings)} + onClick={() => openPluginModal(plugins.Settings)} style={{ cursor: "pointer", color: "var(--text-link)" }} > Settings Plugin diff --git a/src/equicordplugins/_api/userArea.ts b/src/equicordplugins/_api/userArea.ts index 4f1010323..e2feef2dc 100644 --- a/src/equicordplugins/_api/userArea.ts +++ b/src/equicordplugins/_api/userArea.ts @@ -4,6 +4,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { isPluginEnabled } from "@api/PluginManager"; +import betterUserArea from "@equicordplugins/betterUserArea"; import { EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; @@ -31,6 +33,6 @@ export default definePlugin({ }, shouldHideTooltips() { - return Vencord.Plugins.isPluginEnabled("BetterUserArea") && Vencord.Plugins.plugins.BetterUserArea.settings?.store?.removeButtonTooltips; + return isPluginEnabled(betterUserArea.name) && betterUserArea.settings.store.removeButtonTooltips; } }); diff --git a/src/equicordplugins/betterQuickReact/index.tsx b/src/equicordplugins/betterQuickReact/index.tsx index bf3a49fc3..88149b85b 100644 --- a/src/equicordplugins/betterQuickReact/index.tsx +++ b/src/equicordplugins/betterQuickReact/index.tsx @@ -75,7 +75,7 @@ export default definePlugin({ // Add a custom class to identify the quick reactions have been modified and a CSS variable for the number of columns to display { match: /className:(\i)\.wrapper,/, - replace: "className:\"vc-better-quick-react \"+(Vencord.Settings.plugins.BetterQuickReact.compactMode?\"vc-better-quick-react-compact \":\"\")+$1.wrapper,style:{\"--vc-better-quick-react-columns\":$self.settings.store.columns}," + replace: "className:\"vc-better-quick-react \"+($self.settings.store.compactMode?\"vc-better-quick-react-compact \":\"\")+$1.wrapper,style:{\"--vc-better-quick-react-columns\":$self.settings.store.columns}," }, // Scroll handler + Apply the emoji count limit from earlier with custom logic { diff --git a/src/equicordplugins/channelTabs/components/ChannelTabsContainer.tsx b/src/equicordplugins/channelTabs/components/ChannelTabsContainer.tsx index 067d37bc8..4a5cb1b7a 100644 --- a/src/equicordplugins/channelTabs/components/ChannelTabsContainer.tsx +++ b/src/equicordplugins/channelTabs/components/ChannelTabsContainer.tsx @@ -15,6 +15,7 @@ import { useForceUpdater } from "@utils/react"; import { findComponentByCodeLazy, findStoreLazy } from "@webpack"; import { Button, ContextMenuApi, FluxDispatcher, useCallback, useEffect, useRef, UserStore, useState, useStateFromStores } from "@webpack/common"; +import channelTabs from ".."; import BookmarkContainer, { HorizontalScroller } from "./BookmarkContainer"; import ChannelTab, { PreviewTab } from "./ChannelTab"; import { BasicContextMenu } from "./ContextMenus"; @@ -125,7 +126,7 @@ export default function ChannelsTabsContainer(props: BasicChannelTabsProps) { useEffect(() => { if (ref.current) { try { - (Vencord.Plugins.plugins.ChannelTabs as any).containerHeight = ref.current.clientHeight; + channelTabs.containerHeight = ref.current.clientHeight; } catch { } } }, [userId, showBookmarkBar, tabBarPosition]); diff --git a/src/equicordplugins/commandPalette/registry.tsx b/src/equicordplugins/commandPalette/registry.tsx index bd4dcc8e8..b97735860 100644 --- a/src/equicordplugins/commandPalette/registry.tsx +++ b/src/equicordplugins/commandPalette/registry.tsx @@ -5,7 +5,7 @@ */ import { DataStore } from "@api/index"; -import { isPluginEnabled } from "@api/PluginManager"; +import { isPluginEnabled, plugins, startPlugin, stopPlugin } from "@api/PluginManager"; import { SettingsStore } from "@api/Settings"; import { getUserSettingLazy } from "@api/UserSettings"; import { openPluginModal } from "@components/settings/tabs"; @@ -18,6 +18,8 @@ import { ChannelActionCreators, ChannelRouter, ChannelStore, ComponentDispatch, import type { FC, ReactElement, ReactNode } from "react"; import { Settings } from "Vencord"; +import commandPalette from "."; + type CommandHandler = () => void | Promise; type ToastKind = (typeof Toasts.Type)[keyof typeof Toasts.Type]; @@ -1619,10 +1621,7 @@ function refreshPluginToggleCommand(plugin: Plugin) { } function registerPluginToggleCommands() { - const { plugins } = Vencord.Plugins; - const pluginMap = plugins as Record; - - for (const plugin of Object.values(pluginMap)) { + for (const plugin of Object.values(plugins)) { refreshPluginToggleCommand(plugin); } @@ -1631,8 +1630,7 @@ function registerPluginToggleCommands() { if (typeof path !== "string" || !path.startsWith("plugins.")) return; if (!path.endsWith(".enabled")) return; const pluginName = path.slice("plugins.".length, -".enabled".length); - const currentPlugins = Vencord.Plugins.plugins as Record; - const target = currentPlugins[pluginName]; + const target = plugins[pluginName]; if (!target) return; refreshPluginToggleCommand(target); }; @@ -1648,10 +1646,7 @@ function registerPluginToggleCommands() { } function registerPluginSettingsCommands() { - const { plugins } = Vencord.Plugins; - const pluginMap = plugins as Record; - - for (const plugin of Object.values(pluginMap)) { + for (const plugin of Object.values(plugins)) { const keywords = createPluginKeywords(plugin); registerCommand({ id: `settings-plugin-${plugin.name.toLowerCase()}`, @@ -2307,15 +2302,6 @@ function registerFriendCommands() { }); } -function ensurePalettePlugin(): Plugin | null { - const plugin = Vencord.Plugins.plugins[COMMAND_PALETTE_PLUGIN_NAME] as Plugin | undefined; - if (!plugin) { - showToast("Command Palette plugin metadata unavailable.", Toasts.Type.FAILURE); - return null; - } - return plugin; -} - function setPresenceStatus(status: "online" | "idle" | "dnd" | "invisible") { if (!StatusSetting) { showToast("Unable to change status right now.", Toasts.Type.FAILURE); @@ -2374,9 +2360,7 @@ function registerCommandPaletteUtilities() { categoryId: DEFAULT_CATEGORY_ID, tags: [TAG_NAVIGATION, TAG_DEVELOPER], handler: () => { - const plugin = ensurePalettePlugin(); - if (!plugin) return; - openPluginModal(plugin); + openPluginModal(commandPalette); } }); @@ -2522,13 +2506,13 @@ function hotReloadPlugin(plugin: Plugin) { return false; } - const stopped = Vencord.Plugins.stopPlugin(plugin); + const stopped = stopPlugin(plugin); if (!stopped) { showToast(`Failed to stop ${plugin.name}.`, Toasts.Type.FAILURE); return false; } - const started = Vencord.Plugins.startPlugin(plugin); + const started = startPlugin(plugin); if (!started) { showToast(`Failed to restart ${plugin.name}.`, Toasts.Type.FAILURE); return false; @@ -2539,7 +2523,7 @@ function hotReloadPlugin(plugin: Plugin) { } async function reloadAllPlugins() { - const entries = Object.values(Vencord.Plugins.plugins) as Plugin[]; + const entries = Object.values(plugins); let count = 0; for (const plugin of entries) { if (!isPluginEnabled(plugin.name)) continue; @@ -2554,7 +2538,6 @@ async function reloadAllPlugins() { } async function setAllPluginsEnabled(enabled: boolean) { - const { plugins } = Vencord.Plugins; let changed = 0; for (const plugin of Object.values(plugins) as Plugin[]) { const currentlyEnabled = isPluginEnabled(plugin.name); @@ -2624,7 +2607,6 @@ function slugifyActionLabel(label: string) { } function createPluginToolboxCommands(): CommandEntry[] { - const { plugins } = Vencord.Plugins; const pluginMap = plugins as Record; const entries: CommandEntry[] = []; const usedIds = new Set(); diff --git a/src/equicordplugins/customTimestamps/index.tsx b/src/equicordplugins/customTimestamps/index.tsx index a679e77e0..9aa55258a 100644 --- a/src/equicordplugins/customTimestamps/index.tsx +++ b/src/equicordplugins/customTimestamps/index.tsx @@ -8,7 +8,6 @@ import "./style.css"; import { definePluginSettings, useSettings } from "@api/Settings"; import { Divider } from "@components/Divider"; -import ErrorBoundary from "@components/ErrorBoundary"; import { Heading, HeadingPrimary } from "@components/Heading"; import { Link } from "@components/Link"; import { Paragraph } from "@components/Paragraph"; @@ -16,8 +15,9 @@ import { Devs, EquicordDevs } from "@utils/constants"; import { Margins } from "@utils/margins"; import { useForceUpdater } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findComponentByCodeLazy } from "@webpack"; -import { moment, TextInput, useEffect, useRef, UserStore, useState } from "@webpack/common"; +import { moment, TextInput, useEffect, useState } from "@webpack/common"; + +import { DemoMessageContainer, timeFormats } from "./utils"; type TimeFormat = { name: string; @@ -32,57 +32,6 @@ type TimeRowProps = { pluginSettings: any; }; -const timeFormats: Record = { - cozyFormat: { - name: "Cozy mode", - description: "Time format to use in messages on cozy mode", - default: "[calendar]", - offset: 0, - }, - compactFormat: { - name: "Compact mode", - description: "Time format on compact mode and hovering messages", - default: "LT", - offset: 0, - }, - tooltipFormat: { - name: "Tooltip", - description: "Time format to use on tooltips", - default: "LLLL • [relative]", - offset: 0, - }, - ariaLabelFormat: { - name: "Aria label", - description: "Time format to use on aria labels", - default: "[calendar]", - offset: 0, - }, - sameDayFormat: { - name: "Same day", - description: "[calendar] format for today", - default: "[Today at] HH:mm:ss", - offset: 0, - }, - lastDayFormat: { - name: "Last day", - description: "[calendar] format for yesterday", - default: "[Yesterday at] HH:mm:ss", - offset: -1000 * 60 * 60 * 24, - }, - lastWeekFormat: { - name: "Last week", - description: "[calendar] format for within the last week", - default: "ddd DD.MM.YYYY HH:mm:ss", - offset: -1000 * 60 * 60 * 24 * 6, // setting an offset of a week exactly pushes it into "older date" territory as soon as a second passes - }, - sameElseFormat: { - name: "Older date", - description: "[calendar] format for older dates", - default: "ddd DD.MM.YYYY HH:mm:ss", - offset: -1000 * 60 * 60 * 24 * 31, - } -}; - const format = (date: Date, formatTemplate: string): string => { const mmt = moment(date); @@ -122,65 +71,6 @@ const TimeRow = (props: TimeRowProps) => { ); }; -const MessagePreview = findComponentByCodeLazy<{ - author: any, - message: any, - compact: boolean, - isGroupStart: boolean, - className: string, - hideSimpleEmbedContent: boolean; -}>(/previewGuildId:\i,preview:\i,/); -const createBotMessage = findByCodeLazy('username:"Clyde"'); -const populateMessagePrototype = findByCodeLazy("isProbablyAValidSnowflake", "messageReference:"); - -const DemoMessage = (props: { msgId, compact, message, date: Date | undefined, isGroupStart?: boolean; }) => { - const message = createBotMessage({ content: props.message, channelId: "1337", embeds: [] }); - message.author = UserStore.getCurrentUser(); - message.id = props.msgId; - message.timestamp = moment(props.date ?? new Date()); - const user = UserStore.getCurrentUser(); - const populatedMessage = message && populateMessagePrototype(message); - return populatedMessage ? ( -
- -
- ) :
- - {/* @ts-ignore */} - Preview: {Vencord.Plugins.plugins.CustomTimestamps.renderTimestamp(date, "cozy")} - -
; -}; - -const DemoMessageContainer = ErrorBoundary.wrap(() => { - const [isCompact, setIsCompact] = useState(false); - const today = useRef(new Date()); - const yesterday = useRef(new Date(Date.now() + timeFormats.lastDayFormat.offset)); - const lastWeek = useRef(new Date(Date.now() + timeFormats.lastWeekFormat.offset)); - const aMonthAgo = useRef(new Date(Date.now() + timeFormats.sameElseFormat.offset)); - - return ( -
setIsCompact(!isCompact)}> - - - - -
- ); -}, { noop: true }); - const settings = definePluginSettings({ formats: { type: OptionType.COMPONENT, diff --git a/src/equicordplugins/customTimestamps/utils.tsx b/src/equicordplugins/customTimestamps/utils.tsx new file mode 100644 index 000000000..f884bbc30 --- /dev/null +++ b/src/equicordplugins/customTimestamps/utils.tsx @@ -0,0 +1,130 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./style.css"; + +import ErrorBoundary from "@components/ErrorBoundary"; +import { Paragraph } from "@components/Paragraph"; +import { findByCodeLazy, findComponentByCodeLazy } from "@webpack"; +import { moment, useRef, UserStore, useState } from "@webpack/common"; + +import customTimestamps from "."; + +type TimeFormat = { + name: string; + description: string; + default: string; + offset: number; +}; +const MessagePreview = findComponentByCodeLazy<{ + author: any, + message: any, + compact: boolean, + isGroupStart: boolean, + className: string, + hideSimpleEmbedContent: boolean; +}>(/previewGuildId:\i,preview:\i,/); +const createBotMessage = findByCodeLazy('username:"Clyde"'); +const populateMessagePrototype = findByCodeLazy("isProbablyAValidSnowflake", "messageReference:"); + +export const timeFormats: Record = { + cozyFormat: { + name: "Cozy mode", + description: "Time format to use in messages on cozy mode", + default: "[calendar]", + offset: 0, + }, + compactFormat: { + name: "Compact mode", + description: "Time format on compact mode and hovering messages", + default: "LT", + offset: 0, + }, + tooltipFormat: { + name: "Tooltip", + description: "Time format to use on tooltips", + default: "LLLL • [relative]", + offset: 0, + }, + ariaLabelFormat: { + name: "Aria label", + description: "Time format to use on aria labels", + default: "[calendar]", + offset: 0, + }, + sameDayFormat: { + name: "Same day", + description: "[calendar] format for today", + default: "[Today at] HH:mm:ss", + offset: 0, + }, + lastDayFormat: { + name: "Last day", + description: "[calendar] format for yesterday", + default: "[Yesterday at] HH:mm:ss", + offset: -1000 * 60 * 60 * 24, + }, + lastWeekFormat: { + name: "Last week", + description: "[calendar] format for within the last week", + default: "ddd DD.MM.YYYY HH:mm:ss", + offset: -1000 * 60 * 60 * 24 * 6, // setting an offset of a week exactly pushes it into "older date" territory as soon as a second passes + }, + sameElseFormat: { + name: "Older date", + description: "[calendar] format for older dates", + default: "ddd DD.MM.YYYY HH:mm:ss", + offset: -1000 * 60 * 60 * 24 * 31, + } +}; + +const DemoMessage = (props: { msgId, compact, message, date: Date | undefined, isGroupStart?: boolean; }) => { + const message = createBotMessage({ content: props.message, channelId: "1337", embeds: [] }); + message.author = UserStore.getCurrentUser(); + message.id = props.msgId; + message.timestamp = moment(props.date ?? new Date()); + const user = UserStore.getCurrentUser(); + const populatedMessage = message && populateMessagePrototype(message); + return populatedMessage ? ( +
+ +
+ ) :
+ + {/* @ts-ignore */} + Preview: {customTimestamps.renderTimestamp(date, "cozy")} + +
; +}; + +export const DemoMessageContainer = ErrorBoundary.wrap(() => { + const [isCompact, setIsCompact] = useState(false); + const today = useRef(new Date()); + const yesterday = useRef(new Date(Date.now() + timeFormats.lastDayFormat.offset)); + const lastWeek = useRef(new Date(Date.now() + timeFormats.lastWeekFormat.offset)); + const aMonthAgo = useRef(new Date(Date.now() + timeFormats.sameElseFormat.offset)); + + return ( +
setIsCompact(!isCompact)}> + + + + +
+ ); +}, { noop: true }); diff --git a/src/equicordplugins/equicordHelper/pluginButtons.tsx b/src/equicordplugins/equicordHelper/pluginButtons.tsx index b11347b8f..759c60ca5 100644 --- a/src/equicordplugins/equicordHelper/pluginButtons.tsx +++ b/src/equicordplugins/equicordHelper/pluginButtons.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { isPluginEnabled } from "@api/PluginManager"; +import { isPluginEnabled, plugins } from "@api/PluginManager"; import ErrorBoundary from "@components/ErrorBoundary"; import { Logger } from "@utils/Logger"; import { isEquicordGuild, isEquicordSupport } from "@utils/misc"; @@ -19,9 +19,9 @@ export const PluginButtons = ErrorBoundary.wrap(function PluginCards({ message } const msg = message.content?.toLowerCase() ?? ""; const contentWords = (msg.match(/`\w+`/g) ?? []).map(e => e.slice(1, -1)); - const matchedPlugins = Object.keys(Vencord.Plugins.plugins).filter(name => contentWords.includes(name.toLowerCase())); + const matchedPlugins = Object.keys(plugins).filter(name => contentWords.includes(name.toLowerCase())); const matchedPlugin = matchedPlugins.sort((a, b) => b.length - a.length)[0]; - const pluginData = matchedPlugin ? Vencord.Plugins.plugins[matchedPlugin] : null; + const pluginData = matchedPlugin ? plugins[matchedPlugin] : null; const isEquicord = isEquicordGuild(message.channel_id) && isEquicordSupport(message.author.id); const startsWithEnabled = msg.startsWith("enable"); diff --git a/src/equicordplugins/equicordHelper/utils.tsx b/src/equicordplugins/equicordHelper/utils.tsx index ed4d20f5c..a8ab59b93 100644 --- a/src/equicordplugins/equicordHelper/utils.tsx +++ b/src/equicordplugins/equicordHelper/utils.tsx @@ -5,6 +5,7 @@ */ import { showNotice } from "@api/Notices"; +import { plugins, startDependenciesRecursive, startPlugin, stopPlugin } from "@api/PluginManager"; import { Settings } from "@api/Settings"; import { Alerts, Toasts } from "@webpack/common"; @@ -58,13 +59,13 @@ export async function toggleEnabled(name: string) { return true; } - const plugin = Vencord.Plugins.plugins[name]; + const plugin = plugins[name]; const settings = Settings.plugins[plugin.name]; const isEnabled = () => settings.enabled ?? false; const wasEnabled = isEnabled(); if (!wasEnabled) { - const { restartNeeded, failures } = Vencord.Plugins.startDependenciesRecursive(plugin); + const { restartNeeded, failures } = startDependenciesRecursive(plugin); if (failures.length) { console.error(`Failed to start dependencies for ${plugin.name}: ${failures.join(", ")}`); showNotice("Failed to start dependencies: " + failures.join(", "), "Close", () => null); @@ -86,7 +87,7 @@ export async function toggleEnabled(name: string) { return await beforeReturn(settings, wasEnabled); } - const result = wasEnabled ? Vencord.Plugins.stopPlugin(plugin) : Vencord.Plugins.startPlugin(plugin); + const result = wasEnabled ? stopPlugin(plugin) : startPlugin(plugin); if (!result) { settings.enabled = false; diff --git a/src/equicordplugins/loginWithQR/index.tsx b/src/equicordplugins/loginWithQR/index.tsx index 6150f4cb6..7be30e5b4 100644 --- a/src/equicordplugins/loginWithQR/index.tsx +++ b/src/equicordplugins/loginWithQR/index.tsx @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { plugins } from "@api/PluginManager"; import { definePluginSettings } from "@api/Settings"; import { Paragraph } from "@components/Paragraph"; import { EquicordDevs } from "@utils/constants"; @@ -26,7 +27,7 @@ export default definePlugin({ type: OptionType.COMPONENT, description: "Scan a QR code", component() { - if (!Vencord.Plugins.plugins.LoginWithQR.started) + if (!plugins.LoginWithQR.started) return ( Enable the plugin and restart your client to scan a login QR code diff --git a/src/equicordplugins/loginWithQR/ui/modals/QrModal.tsx b/src/equicordplugins/loginWithQR/ui/modals/QrModal.tsx index 11f68fade..a3bc0473c 100644 --- a/src/equicordplugins/loginWithQR/ui/modals/QrModal.tsx +++ b/src/equicordplugins/loginWithQR/ui/modals/QrModal.tsx @@ -5,6 +5,7 @@ */ import { BaseText } from "@components/BaseText"; +import loginWithQR from "@equicordplugins/loginWithQR"; import { images } from "@equicordplugins/loginWithQR/images"; import { getIntlMessage } from "@utils/discord"; import { @@ -248,10 +249,8 @@ function QrModal(props: ModalProps) { }); useEffect(() => { - const plugin = Vencord.Plugins.plugins.LoginWithQR as any; - - plugin.qrModalOpen = true; - return () => void (plugin.qrModalOpen = false); + loginWithQR.qrModalOpen = true; + return () => void (loginWithQR.qrModalOpen = false); }, []); useEffect(() => { diff --git a/src/equicordplugins/musicControls/youtubeMusic/YtmStore.ts b/src/equicordplugins/musicControls/youtubeMusic/YtmStore.ts index 8e538db91..22256b63c 100644 --- a/src/equicordplugins/musicControls/youtubeMusic/YtmStore.ts +++ b/src/equicordplugins/musicControls/youtubeMusic/YtmStore.ts @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { isPluginEnabled } from "@api/PluginManager"; import { Logger } from "@utils/Logger"; import { proxyLazyWebpack } from "@webpack"; import { Flux, FluxDispatcher } from "@webpack/common"; @@ -213,7 +214,7 @@ export const YoutubeMusicStore = proxyLazyWebpack(() => { public openExternal(path: string) { const videoId = path.match(/watch\?v=([\w-]+)/); - const url = Vencord.Plugins.isPluginEnabled("OpenInApp") && videoId + const url = isPluginEnabled("OpenInApp") && videoId ? encodeURI("youtubemusic://openVideo " + videoId[1]) : "https://music.youtube.com" + path; diff --git a/src/equicordplugins/questify/index.tsx b/src/equicordplugins/questify/index.tsx index 613bf1052..38d9cbbe7 100644 --- a/src/equicordplugins/questify/index.tsx +++ b/src/equicordplugins/questify/index.tsx @@ -7,6 +7,7 @@ import "./styles.css"; import { showNotification } from "@api/Notifications"; +import { plugins } from "@api/PluginManager"; import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "@api/ServerList"; import { migratePluginToSettings } from "@api/Settings"; import { ErrorBoundary, openPluginModal } from "@components/index"; @@ -87,7 +88,7 @@ export function QuestButton(): JSX.Element { if (todo === "open-quests") { NavigationRouter.transitionTo(questPath); } else if (todo === "plugin-settings") { - openPluginModal(Vencord.Plugins.plugins.Questify); + openPluginModal(plugins.Questify); } else if (todo === "context-menu") { ContextMenuApi.openContextMenu(event, () => (

Failed to render :(

}), settings, }); diff --git a/src/equicordplugins/themeLibrary/components/ThemeCard.tsx b/src/equicordplugins/themeLibrary/components/ThemeCard.tsx index 6ece6b390..a1ee47071 100644 --- a/src/equicordplugins/themeLibrary/components/ThemeCard.tsx +++ b/src/equicordplugins/themeLibrary/components/ThemeCard.tsx @@ -57,7 +57,7 @@ export const ThemeCard: React.FC = ({ theme, themeLinks, likedTh : [...themeLinks, `${apiUrl}/${theme.id}`]; setThemeLinks(onlineThemeLinks); - Vencord.Settings.themeLinks = onlineThemeLinks; + Settings.themeLinks = onlineThemeLinks; }; const handleThemeAttributesCheck = () => { diff --git a/src/equicordplugins/themeLibrary/components/ThemeTab.tsx b/src/equicordplugins/themeLibrary/components/ThemeTab.tsx index 8a42917cf..588c729fc 100644 --- a/src/equicordplugins/themeLibrary/components/ThemeTab.tsx +++ b/src/equicordplugins/themeLibrary/components/ThemeTab.tsx @@ -59,7 +59,7 @@ const SearchTags = { function ThemeTab() { const [themes, setThemes] = useState([]); const [filteredThemes, setFilteredThemes] = useState([]); - const [themeLinks, setThemeLinks] = useState(Vencord.Settings.themeLinks); + const [themeLinks, setThemeLinks] = useState(Settings.themeLinks); const [likedThemes, setLikedThemes] = useState(); const [searchValue, setSearchValue] = useState({ value: "", status: SearchStatus.ALL }); const [hideWarningCard, setHideWarningCard] = useState(Settings.plugins.ThemeLibrary.hideWarningCard); @@ -123,7 +123,7 @@ function ThemeTab() { }, []); useEffect(() => { - setThemeLinks(Vencord.Settings.themeLinks); + setThemeLinks(Settings.themeLinks); }, []); useEffect(() => { diff --git a/src/equicordplugins/wigglyText/index.tsx b/src/equicordplugins/wigglyText/index.tsx index 61133bac6..1f683e9e6 100644 --- a/src/equicordplugins/wigglyText/index.tsx +++ b/src/equicordplugins/wigglyText/index.tsx @@ -45,7 +45,7 @@ const classMap = [ let styles: HTMLStyleElement; const updateStyles = () => { - const inten = Vencord.Settings.plugins.WigglyText.intensity + "px"; + const inten = settings.store.intensity + "px"; styles.textContent = ` .wiggle-example { list-style-type: disc; diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index 2efc1b45e..0e561c013 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -28,6 +28,7 @@ import { Link } from "@components/Link"; import { Paragraph } from "@components/Paragraph"; import { openSettingsTabModal, UpdaterTab } from "@components/settings"; import { platformName } from "@equicordplugins/equicordHelper/utils"; +import customIdle from "@plugins/customIdle"; import { gitHash, gitHashShort } from "@shared/vencordUserAgent"; import { CONTRIB_ROLE_ID, Devs, DONOR_ROLE_ID, EQUIBOP_CONTRIB_ROLE_ID, EQUICORD_TEAM, GUILD_ID, SUPPORT_CHANNEL_ID, SUPPORT_CHANNEL_IDS, VC_CONTRIB_ROLE_ID, VC_DONOR_ROLE_ID, VC_GUILD_ID, VC_REGULAR_ROLE_ID, VENCORD_CONTRIB_ROLE_ID } from "@utils/constants"; import { sendMessage } from "@utils/discord"; @@ -158,10 +159,10 @@ async function generateDebugInfoMessage() { "NoRPC", "NoProfileThemes", "NoMosaic", "NoRoleHeaders", "NoSystemBadge", "AlwaysAnimate", "ClientTheme", "SoundTroll", "Ingtoninator", "NeverPausePreviews", "IdleAutoRestart", - ].filter(Vencord.Plugins.isPluginEnabled) ?? []).sort(); + ].filter(isPluginEnabled) ?? []).sort(); - if (Vencord.Plugins.isPluginEnabled("CustomIdle") && Vencord.Settings.plugins.CustomIdle.idleTimeout === 0) { - potentiallyProblematicPlugins.push("CustomIdle"); + if (isPluginEnabled(customIdle.name) && customIdle.settings.store.idleTimeout === 0) { + potentiallyProblematicPlugins.push(customIdle.name); } const potentiallyProblematicPluginsNote = "-# Note: These plugins might not be the cause of your problem. They are simply plugins that cause common issues."; diff --git a/src/plugins/devCompanion.dev/util.tsx b/src/plugins/devCompanion.dev/util.tsx index 436856f11..0002e7276 100644 --- a/src/plugins/devCompanion.dev/util.tsx +++ b/src/plugins/devCompanion.dev/util.tsx @@ -5,6 +5,7 @@ */ import { showNotice } from "@api/Notices"; +import { plugins, startDependenciesRecursive, startPlugin, stopPlugin } from "@api/PluginManager"; import { Settings } from "@api/Settings"; import { canonicalizeMatch } from "@utils/patches"; import { CodeFilter, stringMatches, wreq } from "@webpack"; @@ -126,7 +127,7 @@ export function toggleEnabled(name: string, beforeReload: (error?: string) => vo }); } } - const plugin = Vencord.Plugins.plugins[name]; + const plugin = plugins[name]; const settings = Settings.plugins[plugin.name]; @@ -136,7 +137,7 @@ export function toggleEnabled(name: string, beforeReload: (error?: string) => vo // If we're enabling a plugin, make sure all deps are enabled recursively. if (!wasEnabled) { - const { restartNeeded, failures } = Vencord.Plugins.startDependenciesRecursive(plugin); + const { restartNeeded, failures } = startDependenciesRecursive(plugin); if (failures.length) { console.error(`Failed to start dependencies for ${plugin.name}: ${failures.join(", ")}`); showNotice("Failed to start dependencies: " + failures.join(", "), "Close", () => null); @@ -166,7 +167,7 @@ export function toggleEnabled(name: string, beforeReload: (error?: string) => vo return; } - const result = wasEnabled ? Vencord.Plugins.stopPlugin(plugin) : Vencord.Plugins.startPlugin(plugin); + const result = wasEnabled ? stopPlugin(plugin) : startPlugin(plugin); if (!result) { settings.enabled = false; diff --git a/src/plugins/mentionAvatars/index.tsx b/src/plugins/mentionAvatars/index.tsx index 91ffe4da8..1027f0d64 100644 --- a/src/plugins/mentionAvatars/index.tsx +++ b/src/plugins/mentionAvatars/index.tsx @@ -6,8 +6,10 @@ import "./styles.css"; +import { isPluginEnabled } from "@api/PluginManager"; import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; +import showMeYourName from "@plugins/showMeYourName"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { User } from "@vencord/discord-types"; @@ -68,7 +70,7 @@ export default definePlugin({ renderUsername: ErrorBoundary.wrap(({ user, username, showMeYourNameMention }: { user: User, username: string, showMeYourNameMention: JSX.Element | null | undefined; }) => { const [isHovering, setIsHovering] = useState(false); - const nameContent = Vencord.Settings.plugins.ShowMeYourName.enabled && showMeYourNameMention + const nameContent = isPluginEnabled(showMeYourName.name) && showMeYourNameMention ? showMeYourNameMention : <>{getUsernameString(username)}; return ( diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 9c9306469..b5f2c96a5 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -11,6 +11,7 @@ import { NavContextMenuPatchCallback, } from "@api/ContextMenu"; import { updateMessage } from "@api/MessageUpdater"; +import { isPluginEnabled } from "@api/PluginManager"; import { definePluginSettings } from "@api/Settings"; import { disableStyle, enableStyle } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; @@ -110,7 +111,7 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = ( let label; - if (!Vencord.Plugins.isPluginEnabled("MessageLoggerEnhanced")) { + if (!isPluginEnabled("MessageLoggerEnhanced")) { label = "Remove Message History"; } else { label = "Remove Message (Temporary)"; diff --git a/src/plugins/oneko/index.ts b/src/plugins/oneko/index.ts index 750c4a67a..590ae5d0f 100644 --- a/src/plugins/oneko/index.ts +++ b/src/plugins/oneko/index.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { isPluginEnabled } from "@api/PluginManager"; import { definePluginSettings, migratePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; @@ -31,7 +32,7 @@ const settings = definePluginSettings({ }, onChange: () => { // note: cant call the start() function from here. so i just copy pasted it (This was pointed out in the last commit i made. So this is to just clear stuff up for any future devs that work on this :D ) - if (Vencord.Plugins.isPluginEnabled("Oneko")) { + if (isPluginEnabled("Oneko")) { document.getElementById("oneko")?.remove(); fetch("https://raw.githubusercontent.com/adryd325/oneko.js/c4ee66353b11a44e4a5b7e914a81f8d33111555e/oneko.js") .then(x => x.text()) diff --git a/src/plugins/silentTyping/index.tsx b/src/plugins/silentTyping/index.tsx index 8637889ac..b225152b7 100644 --- a/src/plugins/silentTyping/index.tsx +++ b/src/plugins/silentTyping/index.tsx @@ -19,6 +19,7 @@ import { ChatBarButton, ChatBarButtonFactory } from "@api/ChatButtons"; import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands"; import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { plugins } from "@api/PluginManager"; import { definePluginSettings } from "@api/Settings"; import { openPluginModal } from "@components/index"; import { Devs, EquicordDevs } from "@utils/constants"; @@ -162,7 +163,7 @@ const SilentTypingChatToggle: ChatBarButtonFactory = ({ channel, type }) => { channel.guild_id ? toggleLocation(channel.guild_id, effectiveList, defaultHidden) : null; break; case "settings": - openPluginModal(Vencord.Plugins.plugins.SilentTyping); + openPluginModal(plugins.SilentTyping); break; } }