Merge branch 'dev' into immediate-finds
This commit is contained in:
commit
c6b2eeb86d
|
@ -19,8 +19,6 @@
|
||||||
import { proxyLazy } from "@utils/lazy";
|
import { proxyLazy } from "@utils/lazy";
|
||||||
import { findByFactoryCode } from "@webpack";
|
import { findByFactoryCode } from "@webpack";
|
||||||
|
|
||||||
import { Settings } from "./Settings";
|
|
||||||
|
|
||||||
interface UserSettingDefinition<T> {
|
interface UserSettingDefinition<T> {
|
||||||
/**
|
/**
|
||||||
* Get the setting value
|
* Get the setting value
|
||||||
|
@ -40,38 +38,38 @@ interface UserSettingDefinition<T> {
|
||||||
* Stateful React hook for this setting value
|
* Stateful React hook for this setting value
|
||||||
*/
|
*/
|
||||||
useSetting(): T;
|
useSetting(): T;
|
||||||
userSettingDefinitionsAPIGroup: string;
|
userSettingsAPIGroup: string;
|
||||||
userSettingDefinitionsAPIName: string;
|
userSettingsAPIName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UserSettingsDefinitions = findByFactoryCode<Record<PropertyKey, UserSettingDefinition<any>>>('"textAndImages","renderSpoilers"');
|
export const UserSettings = findByFactoryCode<Record<PropertyKey, UserSettingDefinition<any>>>('"textAndImages","renderSpoilers"');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the definition for a setting.
|
* Get the setting with the given setting group and name.
|
||||||
*
|
*
|
||||||
* @param group The setting group
|
* @param group The setting group
|
||||||
* @param name The name of the setting
|
* @param name The name of the setting
|
||||||
*/
|
*/
|
||||||
export function getUserSettingDefinition<T = any>(group: string, name: string): UserSettingDefinition<T> | undefined {
|
export function getUserSetting<T = any>(group: string, name: string): UserSettingDefinition<T> | undefined {
|
||||||
if (!Settings.plugins.UserSettingDefinitionsAPI.enabled) throw new Error("Cannot use UserSettingDefinitionsAPI without setting as dependency.");
|
if (!Vencord.Plugins.isPluginEnabled("UserSettingsAPI")) throw new Error("Cannot use UserSettingsAPI without setting as dependency.");
|
||||||
|
|
||||||
for (const key in UserSettingsDefinitions) {
|
for (const key in UserSettings) {
|
||||||
const userSettingDefinition = UserSettingsDefinitions[key];
|
const userSetting = UserSettings[key];
|
||||||
|
|
||||||
if (userSettingDefinition.userSettingDefinitionsAPIGroup === group && userSettingDefinition.userSettingDefinitionsAPIName === name) {
|
if (userSetting.userSettingsAPIGroup === group && userSetting.userSettingsAPIName === name) {
|
||||||
return userSettingDefinition;
|
return userSetting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazy version of {@link getUserSettingDefinition}
|
* Lazy version of {@link getUserSetting}
|
||||||
*
|
*
|
||||||
* Get the definition for a setting.
|
* Get the setting with the given setting group and name.
|
||||||
*
|
*
|
||||||
* @param group The setting group
|
* @param group The setting group
|
||||||
* @param name The name of the setting
|
* @param name The name of the setting
|
||||||
*/
|
*/
|
||||||
export function getUserSettingDefinitionLazy<T = any>(group: string, name: string) {
|
export function getUserSettingLazy<T = any>(group: string, name: string) {
|
||||||
return proxyLazy(() => getUserSettingDefinition<T>(group, name));
|
return proxyLazy(() => getUserSetting<T>(group, name));
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@ import * as $Notifications from "./Notifications";
|
||||||
import * as $ServerList from "./ServerList";
|
import * as $ServerList from "./ServerList";
|
||||||
import * as $Settings from "./Settings";
|
import * as $Settings from "./Settings";
|
||||||
import * as $Styles from "./Styles";
|
import * as $Styles from "./Styles";
|
||||||
import * as $UserSettingDefinitions from "./UserSettingDefinitions";
|
import * as $UserSettings from "./UserSettings";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An API allowing you to listen to Message Clicks or run your own logic
|
* An API allowing you to listen to Message Clicks or run your own logic
|
||||||
|
@ -119,6 +119,6 @@ export const ChatButtons = $ChatButtons;
|
||||||
export const MessageUpdater = $MessageUpdater;
|
export const MessageUpdater = $MessageUpdater;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An API allowing you to get the definition for an user setting
|
* An API allowing you to get an user setting
|
||||||
*/
|
*/
|
||||||
export const UserSettingDefinitions = $UserSettingDefinitions;
|
export const UserSettings = $UserSettings;
|
||||||
|
|
|
@ -20,8 +20,8 @@ import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "UserSettingDefinitionsAPI",
|
name: "UserSettingsAPI",
|
||||||
description: "Patches Discord's UserSettingDefinitions to expose their group and name.",
|
description: "Patches Discord's UserSettings to expose their group and name.",
|
||||||
authors: [Devs.Nuckyz],
|
authors: [Devs.Nuckyz],
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
|
@ -31,17 +31,17 @@ export default definePlugin({
|
||||||
// Main setting definition
|
// Main setting definition
|
||||||
{
|
{
|
||||||
match: /(?<=INFREQUENT_USER_ACTION.{0,20},)useSetting:/,
|
match: /(?<=INFREQUENT_USER_ACTION.{0,20},)useSetting:/,
|
||||||
replace: "userSettingDefinitionsAPIGroup:arguments[0],userSettingDefinitionsAPIName:arguments[1],$&"
|
replace: "userSettingsAPIGroup:arguments[0],userSettingsAPIName:arguments[1],$&"
|
||||||
},
|
},
|
||||||
// Selective wrapper
|
// Selective wrapper
|
||||||
{
|
{
|
||||||
match: /updateSetting:.{0,100}SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE/,
|
match: /updateSetting:.{0,100}SELECTIVELY_SYNCED_USER_SETTINGS_UPDATE/,
|
||||||
replace: "userSettingDefinitionsAPIGroup:arguments[0].userSettingDefinitionsAPIGroup,userSettingDefinitionsAPIName:arguments[0].userSettingDefinitionsAPIName,$&"
|
replace: "userSettingsAPIGroup:arguments[0].userSettingsAPIGroup,userSettingsAPIName:arguments[0].userSettingsAPIName,$&"
|
||||||
},
|
},
|
||||||
// Override wrapper
|
// Override wrapper
|
||||||
{
|
{
|
||||||
match: /updateSetting:.{0,60}USER_SETTINGS_OVERRIDE_CLEAR/,
|
match: /updateSetting:.{0,60}USER_SETTINGS_OVERRIDE_CLEAR/,
|
||||||
replace: "userSettingDefinitionsAPIGroup:arguments[0].userSettingDefinitionsAPIGroup,userSettingDefinitionsAPIName:arguments[0].userSettingDefinitionsAPIName,$&"
|
replace: "userSettingsAPIGroup:arguments[0].userSettingsAPIGroup,userSettingsAPIName:arguments[0].userSettingsAPIName,$&"
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import { ImageIcon } from "@components/Icons";
|
import { ImageIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getCurrentGuild, openImageModal } from "@utils/discord";
|
import { getCurrentGuild, openImageModal } from "@utils/discord";
|
||||||
|
@ -15,7 +15,7 @@ import { Clipboard, GuildStore, Menu, PermissionStore } from "@webpack/common";
|
||||||
|
|
||||||
const GuildSettingsActions = findByProps("open", "selectRole", "updateGuild");
|
const GuildSettingsActions = findByProps("open", "selectRole", "updateGuild");
|
||||||
|
|
||||||
const DeveloperMode = getUserSettingDefinitionLazy("appearance", "developerMode")!;
|
const DeveloperMode = getUserSettingLazy("appearance", "developerMode")!;
|
||||||
|
|
||||||
function PencilIcon() {
|
function PencilIcon() {
|
||||||
return (
|
return (
|
||||||
|
@ -65,7 +65,7 @@ export default definePlugin({
|
||||||
name: "BetterRoleContext",
|
name: "BetterRoleContext",
|
||||||
description: "Adds options to copy role color / edit role / view role icon when right clicking roles in the user profile",
|
description: "Adds options to copy role color / edit role / view role icon when right clicking roles in the user profile",
|
||||||
authors: [Devs.Ven, Devs.goodbee],
|
authors: [Devs.Ven, Devs.goodbee],
|
||||||
dependencies: ["UserSettingDefinitionsAPI"],
|
dependencies: ["UserSettingsAPI"],
|
||||||
|
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import { ErrorCard } from "@components/ErrorCard";
|
import { ErrorCard } from "@components/ErrorCard";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
@ -33,7 +33,7 @@ const useProfileThemeStyle = findByCode("profileThemeStyle:", "--profile-gradien
|
||||||
const ActivityComponent = findComponentByCode("onOpenGameProfile");
|
const ActivityComponent = findComponentByCode("onOpenGameProfile");
|
||||||
const ActivityClassName = findByProps("activity", "buttonColor");
|
const ActivityClassName = findByProps("activity", "buttonColor");
|
||||||
|
|
||||||
const ShowCurrentGame = getUserSettingDefinitionLazy<boolean>("status", "showCurrentGame")!;
|
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame")!;
|
||||||
|
|
||||||
async function getApplicationAsset(key: string): Promise<string> {
|
async function getApplicationAsset(key: string): Promise<string> {
|
||||||
if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\/attachments\//.test(key)) return "mp:" + key.replace(/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//, "");
|
if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\/attachments\//.test(key)) return "mp:" + key.replace(/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//, "");
|
||||||
|
@ -393,7 +393,7 @@ export default definePlugin({
|
||||||
name: "CustomRPC",
|
name: "CustomRPC",
|
||||||
description: "Allows you to set a custom rich presence.",
|
description: "Allows you to set a custom rich presence.",
|
||||||
authors: [Devs.captain, Devs.AutumnVN, Devs.nin0dev],
|
authors: [Devs.captain, Devs.AutumnVN, Devs.nin0dev],
|
||||||
dependencies: ["UserSettingDefinitionsAPI"],
|
dependencies: ["UserSettingsAPI"],
|
||||||
start: setRpc,
|
start: setRpc,
|
||||||
stop: () => setRpc(true),
|
stop: () => setRpc(true),
|
||||||
settings,
|
settings,
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { disableStyle, enableStyle } from "@api/Styles";
|
import { disableStyle, enableStyle } from "@api/Styles";
|
||||||
import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
@ -28,7 +28,7 @@ import style from "./style.css?managed";
|
||||||
|
|
||||||
const Button = findComponentByCode("Button.Sizes.NONE,disabled:");
|
const Button = findComponentByCode("Button.Sizes.NONE,disabled:");
|
||||||
|
|
||||||
const ShowCurrentGame = getUserSettingDefinitionLazy<boolean>("status", "showCurrentGame")!;
|
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame")!;
|
||||||
|
|
||||||
function makeIcon(showCurrentGame?: boolean) {
|
function makeIcon(showCurrentGame?: boolean) {
|
||||||
const { oldIcon } = settings.use(["oldIcon"]);
|
const { oldIcon } = settings.use(["oldIcon"]);
|
||||||
|
@ -87,7 +87,7 @@ export default definePlugin({
|
||||||
name: "GameActivityToggle",
|
name: "GameActivityToggle",
|
||||||
description: "Adds a button next to the mic and deafen button to toggle game activity.",
|
description: "Adds a button next to the mic and deafen button to toggle game activity.",
|
||||||
authors: [Devs.Nuckyz, Devs.RuukuLada],
|
authors: [Devs.Nuckyz, Devs.RuukuLada],
|
||||||
dependencies: ["UserSettingDefinitionsAPI"],
|
dependencies: ["UserSettingsAPI"],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import * as DataStore from "@api/DataStore";
|
import * as DataStore from "@api/DataStore";
|
||||||
import { definePluginSettings, Settings } from "@api/Settings";
|
import { definePluginSettings, Settings } from "@api/Settings";
|
||||||
import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
@ -28,7 +28,7 @@ interface IgnoredActivity {
|
||||||
|
|
||||||
const RunningGameStore = findStore("RunningGameStore");
|
const RunningGameStore = findStore("RunningGameStore");
|
||||||
|
|
||||||
const ShowCurrentGame = getUserSettingDefinitionLazy("status", "showCurrentGame")!;
|
const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!;
|
||||||
|
|
||||||
function ToggleIcon(activity: IgnoredActivity, tooltipText: string, path: string, fill: string) {
|
function ToggleIcon(activity: IgnoredActivity, tooltipText: string, path: string, fill: string) {
|
||||||
return (
|
return (
|
||||||
|
@ -208,7 +208,7 @@ export default definePlugin({
|
||||||
name: "IgnoreActivities",
|
name: "IgnoreActivities",
|
||||||
authors: [Devs.Nuckyz],
|
authors: [Devs.Nuckyz],
|
||||||
description: "Ignore activities from showing up on your status ONLY. You can configure which ones are specifically ignored from the Registered Games and Activities tabs, or use the general settings below.",
|
description: "Ignore activities from showing up on your status ONLY. You can configure which ones are specifically ignored from the Registered Games and Activities tabs, or use the general settings below.",
|
||||||
dependencies: ["UserSettingDefinitionsAPI"],
|
dependencies: ["UserSettingsAPI"],
|
||||||
|
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
|
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
|
||||||
import { updateMessage } from "@api/MessageUpdater";
|
import { updateMessage } from "@api/MessageUpdater";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingDefinitionLazy } from "@api/UserSettingDefinitions";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants.js";
|
import { Devs } from "@utils/constants.js";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
|
@ -54,7 +54,7 @@ const ChannelMessage = findComponentByCode("childrenExecutedCommand:", ".hideAcc
|
||||||
const SearchResultClasses = findByProps("message", "searchResult");
|
const SearchResultClasses = findByProps("message", "searchResult");
|
||||||
const EmbedClasses = findByProps("embedAuthorIcon", "embedAuthor", "embedAuthor");
|
const EmbedClasses = findByProps("embedAuthorIcon", "embedAuthor", "embedAuthor");
|
||||||
|
|
||||||
const MessageDisplayCompact = getUserSettingDefinitionLazy("textAndImages", "messageDisplayCompact")!;
|
const MessageDisplayCompact = getUserSettingLazy("textAndImages", "messageDisplayCompact")!;
|
||||||
|
|
||||||
const messageLinkRegex = /(?<!<)https?:\/\/(?:\w+\.)?discord(?:app)?\.com\/channels\/(?:\d{17,20}|@me)\/(\d{17,20})\/(\d{17,20})/g;
|
const messageLinkRegex = /(?<!<)https?:\/\/(?:\w+\.)?discord(?:app)?\.com\/channels\/(?:\d{17,20}|@me)\/(\d{17,20})\/(\d{17,20})/g;
|
||||||
const tenorRegex = /^https:\/\/(?:www\.)?tenor\.com\//;
|
const tenorRegex = /^https:\/\/(?:www\.)?tenor\.com\//;
|
||||||
|
@ -365,7 +365,7 @@ export default definePlugin({
|
||||||
name: "MessageLinkEmbeds",
|
name: "MessageLinkEmbeds",
|
||||||
description: "Adds a preview to messages that link another message",
|
description: "Adds a preview to messages that link another message",
|
||||||
authors: [Devs.TheSun, Devs.Ven, Devs.RyanCaoDev],
|
authors: [Devs.TheSun, Devs.Ven, Devs.RyanCaoDev],
|
||||||
dependencies: ["MessageAccessoriesAPI", "MessageUpdaterAPI", "UserSettingDefinitionsAPI"],
|
dependencies: ["MessageAccessoriesAPI", "MessageUpdaterAPI", "UserSettingsAPI"],
|
||||||
|
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue