Misc: Move to proper imports
This commit is contained in:
parent
43d68add4c
commit
8ce7150ca3
24 changed files with 197 additions and 174 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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{" "}
|
||||
<a
|
||||
role="button"
|
||||
onClick={() => openPluginModal(Vencord.Plugins.plugins.Settings)}
|
||||
onClick={() => openPluginModal(plugins.Settings)}
|
||||
style={{ cursor: "pointer", color: "var(--text-link)" }}
|
||||
>
|
||||
Settings Plugin
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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<void>;
|
||||
|
||||
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<string, Plugin>;
|
||||
|
||||
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<string, Plugin>;
|
||||
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<string, Plugin>;
|
||||
|
||||
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<string, Plugin>;
|
||||
const entries: CommandEntry[] = [];
|
||||
const usedIds = new Set<string>();
|
||||
|
|
|
|||
|
|
@ -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<string, TimeFormat> = {
|
||||
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 ? (
|
||||
<div className="vc-cmt-demo-message">
|
||||
<MessagePreview
|
||||
author={{ ...user, nick: user.globalName || user.username }}
|
||||
message={populatedMessage}
|
||||
compact={props.compact}
|
||||
isGroupStart={props.isGroupStart || false}
|
||||
className="vc-cmt-demo-message-preview"
|
||||
hideSimpleEmbedContent={true}
|
||||
/>
|
||||
</div>
|
||||
) : <div className="vc-cmt-demo-message">
|
||||
<Paragraph>
|
||||
{/* @ts-ignore */}
|
||||
<b>Preview:</b> {Vencord.Plugins.plugins.CustomTimestamps.renderTimestamp(date, "cozy")}
|
||||
</Paragraph>
|
||||
</div>;
|
||||
};
|
||||
|
||||
const DemoMessageContainer = ErrorBoundary.wrap(() => {
|
||||
const [isCompact, setIsCompact] = useState(false);
|
||||
const today = useRef<Date>(new Date());
|
||||
const yesterday = useRef<Date>(new Date(Date.now() + timeFormats.lastDayFormat.offset));
|
||||
const lastWeek = useRef<Date>(new Date(Date.now() + timeFormats.lastWeekFormat.offset));
|
||||
const aMonthAgo = useRef<Date>(new Date(Date.now() + timeFormats.sameElseFormat.offset));
|
||||
|
||||
return (
|
||||
<div className={"vc-cmt-demo-message-container"} onClick={() => setIsCompact(!isCompact)}>
|
||||
<DemoMessage compact={isCompact} msgId={"1337"}
|
||||
message={`Click me to switch to ${isCompact ? "cozy" : "compact"} mode`} isGroupStart={true}
|
||||
date={aMonthAgo.current} />
|
||||
<DemoMessage compact={isCompact} msgId={"1338"} message={"This message was sent in the last week"}
|
||||
isGroupStart={true} date={lastWeek.current} />
|
||||
<DemoMessage compact={isCompact} msgId={"1339"} message={"Hover over timestamps to see tooltip formats"}
|
||||
isGroupStart={true} date={yesterday.current} />
|
||||
<DemoMessage compact={isCompact} msgId={"1340"} message={"Edit the formats below to see them live update here"} isGroupStart={true}
|
||||
date={today.current} />
|
||||
</div>
|
||||
);
|
||||
}, { noop: true });
|
||||
|
||||
const settings = definePluginSettings({
|
||||
formats: {
|
||||
type: OptionType.COMPONENT,
|
||||
|
|
|
|||
130
src/equicordplugins/customTimestamps/utils.tsx
Normal file
130
src/equicordplugins/customTimestamps/utils.tsx
Normal file
|
|
@ -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<string, TimeFormat> = {
|
||||
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 ? (
|
||||
<div className="vc-cmt-demo-message">
|
||||
<MessagePreview
|
||||
author={{ ...user, nick: user.globalName || user.username }}
|
||||
message={populatedMessage}
|
||||
compact={props.compact}
|
||||
isGroupStart={props.isGroupStart || false}
|
||||
className="vc-cmt-demo-message-preview"
|
||||
hideSimpleEmbedContent={true}
|
||||
/>
|
||||
</div>
|
||||
) : <div className="vc-cmt-demo-message">
|
||||
<Paragraph>
|
||||
{/* @ts-ignore */}
|
||||
<b>Preview:</b> {customTimestamps.renderTimestamp(date, "cozy")}
|
||||
</Paragraph>
|
||||
</div>;
|
||||
};
|
||||
|
||||
export const DemoMessageContainer = ErrorBoundary.wrap(() => {
|
||||
const [isCompact, setIsCompact] = useState(false);
|
||||
const today = useRef<Date>(new Date());
|
||||
const yesterday = useRef<Date>(new Date(Date.now() + timeFormats.lastDayFormat.offset));
|
||||
const lastWeek = useRef<Date>(new Date(Date.now() + timeFormats.lastWeekFormat.offset));
|
||||
const aMonthAgo = useRef<Date>(new Date(Date.now() + timeFormats.sameElseFormat.offset));
|
||||
|
||||
return (
|
||||
<div className={"vc-cmt-demo-message-container"} onClick={() => setIsCompact(!isCompact)}>
|
||||
<DemoMessage compact={isCompact} msgId={"1337"}
|
||||
message={`Click me to switch to ${isCompact ? "cozy" : "compact"} mode`} isGroupStart={true}
|
||||
date={aMonthAgo.current} />
|
||||
<DemoMessage compact={isCompact} msgId={"1338"} message={"This message was sent in the last week"}
|
||||
isGroupStart={true} date={lastWeek.current} />
|
||||
<DemoMessage compact={isCompact} msgId={"1339"} message={"Hover over timestamps to see tooltip formats"}
|
||||
isGroupStart={true} date={yesterday.current} />
|
||||
<DemoMessage compact={isCompact} msgId={"1340"} message={"Edit the formats below to see them live update here"} isGroupStart={true}
|
||||
date={today.current} />
|
||||
</div>
|
||||
);
|
||||
}, { noop: true });
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Paragraph>
|
||||
Enable the plugin and restart your client to scan a login QR code
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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, () => (
|
||||
<Menu.Menu
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export default definePlugin({
|
|||
find: /\i\.\i\.STICKER_MESSAGE/,
|
||||
replacement: {
|
||||
match: /}\),\(null!=\i\?\i:(\i)\)\.name]}\);/,
|
||||
replace: "$& if(Vencord.Settings.plugins.StickerBlocker.blockedStickers.split(\", \").includes($1.id)) { return($self.blockedComponent($1)) }"
|
||||
replace: "$& if($self.isBlocked($1.id)) return($self.blockedComponent($1));"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
@ -142,6 +142,13 @@ export default definePlugin({
|
|||
start() {
|
||||
DataStore.createStore("StickerBlocker", "data");
|
||||
},
|
||||
isBlocked(stickerId) {
|
||||
if (settings.store.blockedStickers.split(", ").includes(stickerId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
blockedComponent: ErrorBoundary.wrap(blockedComponentRender, { fallback: () => <p style={{ color: "red" }}>Failed to render :(</p> }),
|
||||
settings,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export const ThemeCard: React.FC<ThemeCardProps> = ({ theme, themeLinks, likedTh
|
|||
: [...themeLinks, `${apiUrl}/${theme.id}`];
|
||||
|
||||
setThemeLinks(onlineThemeLinks);
|
||||
Vencord.Settings.themeLinks = onlineThemeLinks;
|
||||
Settings.themeLinks = onlineThemeLinks;
|
||||
};
|
||||
|
||||
const handleThemeAttributesCheck = () => {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ const SearchTags = {
|
|||
function ThemeTab() {
|
||||
const [themes, setThemes] = useState<Theme[]>([]);
|
||||
const [filteredThemes, setFilteredThemes] = useState<Theme[]>([]);
|
||||
const [themeLinks, setThemeLinks] = useState(Vencord.Settings.themeLinks);
|
||||
const [themeLinks, setThemeLinks] = useState(Settings.themeLinks);
|
||||
const [likedThemes, setLikedThemes] = useState<ThemeLikeProps>();
|
||||
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(() => {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.";
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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)";
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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())
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue