Merge branch 'main' of https://www.coastalcommits.com/CoastalCommitsArchival/github.com-Vendicated-Vencord
This commit is contained in:
commit
a57ee6d726
25 changed files with 482 additions and 126 deletions
6
.vscode/extensions.json
vendored
6
.vscode/extensions.json
vendored
|
@ -1,11 +1,9 @@
|
||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"dbaeumer.vscode-eslint",
|
"dbaeumer.vscode-eslint",
|
||||||
"eamodio.gitlens",
|
|
||||||
"EditorConfig.EditorConfig",
|
"EditorConfig.EditorConfig",
|
||||||
"ExodiusStudios.comment-anchors",
|
|
||||||
"formulahendry.auto-rename-tag",
|
|
||||||
"GregorBiswanger.json2ts",
|
"GregorBiswanger.json2ts",
|
||||||
"stylelint.vscode-stylelint"
|
"stylelint.vscode-stylelint",
|
||||||
|
"Vendicated.vencord-companion"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,8 @@ function ReplacementInput({ replacement, setReplacement, replacementError }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Forms.FormTitle>replacement</Forms.FormTitle>
|
{/* FormTitle adds a class if className is not set, so we set it to an empty string to prevent that */}
|
||||||
|
<Forms.FormTitle className="">replacement</Forms.FormTitle>
|
||||||
<TextInput
|
<TextInput
|
||||||
value={replacement?.toString()}
|
value={replacement?.toString()}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
@ -188,7 +189,7 @@ function ReplacementInput({ replacement, setReplacement, replacementError }) {
|
||||||
/>
|
/>
|
||||||
{!isFunc && (
|
{!isFunc && (
|
||||||
<div className="vc-text-selectable">
|
<div className="vc-text-selectable">
|
||||||
<Forms.FormTitle>Cheat Sheet</Forms.FormTitle>
|
<Forms.FormTitle className={Margins.top8}>Cheat Sheet</Forms.FormTitle>
|
||||||
{Object.entries({
|
{Object.entries({
|
||||||
"\\i": "Special regex escape sequence that matches identifiers (varnames, classnames, etc.)",
|
"\\i": "Special regex escape sequence that matches identifiers (varnames, classnames, etc.)",
|
||||||
"$$": "Insert a $",
|
"$$": "Insert a $",
|
||||||
|
@ -220,11 +221,12 @@ function ReplacementInput({ replacement, setReplacement, replacementError }) {
|
||||||
|
|
||||||
interface FullPatchInputProps {
|
interface FullPatchInputProps {
|
||||||
setFind(v: string): void;
|
setFind(v: string): void;
|
||||||
|
setParsedFind(v: string | RegExp): void;
|
||||||
setMatch(v: string): void;
|
setMatch(v: string): void;
|
||||||
setReplacement(v: string | ReplaceFn): void;
|
setReplacement(v: string | ReplaceFn): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function FullPatchInput({ setFind, setMatch, setReplacement }: FullPatchInputProps) {
|
function FullPatchInput({ setFind, setParsedFind, setMatch, setReplacement }: FullPatchInputProps) {
|
||||||
const [fullPatch, setFullPatch] = React.useState<string>("");
|
const [fullPatch, setFullPatch] = React.useState<string>("");
|
||||||
const [fullPatchError, setFullPatchError] = React.useState<string>("");
|
const [fullPatchError, setFullPatchError] = React.useState<string>("");
|
||||||
|
|
||||||
|
@ -233,6 +235,7 @@ function FullPatchInput({ setFind, setMatch, setReplacement }: FullPatchInputPro
|
||||||
setFullPatchError("");
|
setFullPatchError("");
|
||||||
|
|
||||||
setFind("");
|
setFind("");
|
||||||
|
setParsedFind("");
|
||||||
setMatch("");
|
setMatch("");
|
||||||
setReplacement("");
|
setReplacement("");
|
||||||
return;
|
return;
|
||||||
|
@ -256,7 +259,8 @@ function FullPatchInput({ setFind, setMatch, setReplacement }: FullPatchInputPro
|
||||||
if (!parsed.replacement.match) throw new Error("No 'replacement.match' field");
|
if (!parsed.replacement.match) throw new Error("No 'replacement.match' field");
|
||||||
if (!parsed.replacement.replace) throw new Error("No 'replacement.replace' field");
|
if (!parsed.replacement.replace) throw new Error("No 'replacement.replace' field");
|
||||||
|
|
||||||
setFind(parsed.find);
|
setFind(parsed.find instanceof RegExp ? parsed.find.toString() : parsed.find);
|
||||||
|
setParsedFind(parsed.find);
|
||||||
setMatch(parsed.replacement.match instanceof RegExp ? parsed.replacement.match.source : parsed.replacement.match);
|
setMatch(parsed.replacement.match instanceof RegExp ? parsed.replacement.match.source : parsed.replacement.match);
|
||||||
setReplacement(parsed.replacement.replace);
|
setReplacement(parsed.replacement.replace);
|
||||||
setFullPatchError("");
|
setFullPatchError("");
|
||||||
|
@ -266,7 +270,7 @@ function FullPatchInput({ setFind, setMatch, setReplacement }: FullPatchInputPro
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Forms.FormText>Paste your full JSON patch here to fill out the fields</Forms.FormText>
|
<Forms.FormText className={Margins.bottom8}>Paste your full JSON patch here to fill out the fields</Forms.FormText>
|
||||||
<TextArea value={fullPatch} onChange={setFullPatch} onBlur={update} />
|
<TextArea value={fullPatch} onChange={setFullPatch} onBlur={update} />
|
||||||
{fullPatchError !== "" && <Forms.FormText style={{ color: "var(--text-danger)" }}>{fullPatchError}</Forms.FormText>}
|
{fullPatchError !== "" && <Forms.FormText style={{ color: "var(--text-danger)" }}>{fullPatchError}</Forms.FormText>}
|
||||||
</>;
|
</>;
|
||||||
|
@ -274,6 +278,7 @@ function FullPatchInput({ setFind, setMatch, setReplacement }: FullPatchInputPro
|
||||||
|
|
||||||
function PatchHelper() {
|
function PatchHelper() {
|
||||||
const [find, setFind] = React.useState<string>("");
|
const [find, setFind] = React.useState<string>("");
|
||||||
|
const [parsedFind, setParsedFind] = React.useState<string | RegExp>("");
|
||||||
const [match, setMatch] = React.useState<string>("");
|
const [match, setMatch] = React.useState<string>("");
|
||||||
const [replacement, setReplacement] = React.useState<string | ReplaceFn>("");
|
const [replacement, setReplacement] = React.useState<string | ReplaceFn>("");
|
||||||
|
|
||||||
|
@ -285,20 +290,34 @@ function PatchHelper() {
|
||||||
const code = React.useMemo(() => {
|
const code = React.useMemo(() => {
|
||||||
return `
|
return `
|
||||||
{
|
{
|
||||||
find: ${JSON.stringify(find)},
|
find: ${parsedFind instanceof RegExp ? parsedFind.toString() : JSON.stringify(parsedFind)},
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /${match.replace(/(?<!\\)\//g, "\\/")}/,
|
match: /${match.replace(/(?<!\\)\//g, "\\/")}/,
|
||||||
replace: ${typeof replacement === "function" ? replacement.toString() : JSON.stringify(replacement)}
|
replace: ${typeof replacement === "function" ? replacement.toString() : JSON.stringify(replacement)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`.trim();
|
`.trim();
|
||||||
}, [find, match, replacement]);
|
}, [parsedFind, match, replacement]);
|
||||||
|
|
||||||
function onFindChange(v: string) {
|
function onFindChange(v: string) {
|
||||||
setFindError(void 0);
|
setFindError(void 0);
|
||||||
setFind(v);
|
setFind(v);
|
||||||
if (v.length) {
|
}
|
||||||
findCandidates({ find: v, setModule, setError: setFindError });
|
|
||||||
|
function onFindBlur() {
|
||||||
|
try {
|
||||||
|
let parsedFind = find as string | RegExp;
|
||||||
|
if (/^\/.+?\/$/.test(find)) parsedFind = new RegExp(find.slice(1, -1));
|
||||||
|
|
||||||
|
setFindError(void 0);
|
||||||
|
setFind(find);
|
||||||
|
setParsedFind(parsedFind);
|
||||||
|
|
||||||
|
if (find.length) {
|
||||||
|
findCandidates({ find: parsedFind, setModule, setError: setFindError });
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
setFindError((e as Error).message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,19 +336,21 @@ function PatchHelper() {
|
||||||
<Forms.FormTitle>full patch</Forms.FormTitle>
|
<Forms.FormTitle>full patch</Forms.FormTitle>
|
||||||
<FullPatchInput
|
<FullPatchInput
|
||||||
setFind={onFindChange}
|
setFind={onFindChange}
|
||||||
|
setParsedFind={setParsedFind}
|
||||||
setMatch={onMatchChange}
|
setMatch={onMatchChange}
|
||||||
setReplacement={setReplacement}
|
setReplacement={setReplacement}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Forms.FormTitle>find</Forms.FormTitle>
|
<Forms.FormTitle className={Margins.top8}>find</Forms.FormTitle>
|
||||||
<TextInput
|
<TextInput
|
||||||
type="text"
|
type="text"
|
||||||
value={find}
|
value={find}
|
||||||
onChange={onFindChange}
|
onChange={onFindChange}
|
||||||
|
onBlur={onFindBlur}
|
||||||
error={findError}
|
error={findError}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Forms.FormTitle>match</Forms.FormTitle>
|
<Forms.FormTitle className={Margins.top8}>match</Forms.FormTitle>
|
||||||
<CheckedTextInput
|
<CheckedTextInput
|
||||||
value={match}
|
value={match}
|
||||||
onChange={onMatchChange}
|
onChange={onMatchChange}
|
||||||
|
@ -342,6 +363,7 @@ function PatchHelper() {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div className={Margins.top8} />
|
||||||
<ReplacementInput
|
<ReplacementInput
|
||||||
replacement={replacement}
|
replacement={replacement}
|
||||||
setReplacement={setReplacement}
|
setReplacement={setReplacement}
|
||||||
|
|
|
@ -35,6 +35,7 @@ export const ALLOWED_PROTOCOLS = [
|
||||||
"steam:",
|
"steam:",
|
||||||
"spotify:",
|
"spotify:",
|
||||||
"com.epicgames.launcher:",
|
"com.epicgames.launcher:",
|
||||||
|
"tidal:"
|
||||||
];
|
];
|
||||||
|
|
||||||
export const IS_VANILLA = /* @__PURE__ */ process.argv.includes("--vanilla");
|
export const IS_VANILLA = /* @__PURE__ */ process.argv.includes("--vanilla");
|
||||||
|
|
|
@ -30,6 +30,9 @@ import { i18n, React } from "@webpack/common";
|
||||||
|
|
||||||
import gitHash from "~git-hash";
|
import gitHash from "~git-hash";
|
||||||
|
|
||||||
|
type SectionType = "HEADER" | "DIVIDER" | "CUSTOM";
|
||||||
|
type SectionTypes = Record<SectionType, SectionType>;
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "Settings",
|
name: "Settings",
|
||||||
description: "Adds Settings UI and debug info",
|
description: "Adds Settings UI and debug info",
|
||||||
|
@ -41,34 +44,18 @@ export default definePlugin({
|
||||||
find: ".versionHash",
|
find: ".versionHash",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /\[\(0,.{1,3}\.jsxs?\)\((.{1,10}),(\{[^{}}]+\{.{0,20}.versionHash,.+?\})\)," "/,
|
match: /\[\(0,\i\.jsxs?\)\((.{1,10}),(\{[^{}}]+\{.{0,20}.versionHash,.+?\})\)," "/,
|
||||||
replace: (m, component, props) => {
|
replace: (m, component, props) => {
|
||||||
props = props.replace(/children:\[.+\]/, "");
|
props = props.replace(/children:\[.+\]/, "");
|
||||||
return `${m},$self.makeInfoElements(${component}, ${props})`;
|
return `${m},$self.makeInfoElements(${component}, ${props})`;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /copyValue:\i\.join\(" "\)/,
|
||||||
|
replace: "$& + $self.getInfoString()"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// Discord Stable
|
|
||||||
// FIXME: remove once change merged to stable
|
|
||||||
{
|
|
||||||
find: "Messages.ACTIVITY_SETTINGS",
|
|
||||||
replacement: {
|
|
||||||
get match() {
|
|
||||||
switch (Settings.plugins.Settings.settingsLocation) {
|
|
||||||
case "top": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.USER_SETTINGS/;
|
|
||||||
case "aboveNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.BILLING_SETTINGS/;
|
|
||||||
case "belowNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.APP_SETTINGS/;
|
|
||||||
case "belowActivity": return /(?<=\{section:(\i\.\i)\.DIVIDER},)\{section:"changelog"/;
|
|
||||||
case "bottom": return /\{section:(\i\.\i)\.CUSTOM,\s*element:.+?}/;
|
|
||||||
case "aboveActivity":
|
|
||||||
default:
|
|
||||||
return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.ACTIVITY_SETTINGS/;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
replace: "...$self.makeSettingsCategories($1),$&"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Discord Canary
|
// Discord Canary
|
||||||
{
|
{
|
||||||
find: "Messages.ACTIVITY_SETTINGS",
|
find: "Messages.ACTIVITY_SETTINGS",
|
||||||
|
@ -77,6 +64,13 @@ export default definePlugin({
|
||||||
replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}`
|
replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
find: "useDefaultUserSettingsSections:function",
|
||||||
|
replacement: {
|
||||||
|
match: /(?<=useDefaultUserSettingsSections:function\(\){return )(\i)\}/,
|
||||||
|
replace: "$self.wrapSettingsHook($1)}"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
|
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
|
||||||
replacement: {
|
replacement: {
|
||||||
|
@ -86,9 +80,9 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
customSections: [] as ((SectionTypes: Record<string, unknown>) => any)[],
|
customSections: [] as ((SectionTypes: SectionTypes) => any)[],
|
||||||
|
|
||||||
makeSettingsCategories(SectionTypes: Record<string, unknown>) {
|
makeSettingsCategories(SectionTypes: SectionTypes) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
section: SectionTypes.HEADER,
|
section: SectionTypes.HEADER,
|
||||||
|
@ -154,6 +148,8 @@ export default definePlugin({
|
||||||
if (settingsLocation === "bottom") return firstChild === "LOGOUT";
|
if (settingsLocation === "bottom") return firstChild === "LOGOUT";
|
||||||
if (settingsLocation === "belowActivity") return firstChild === "CHANGELOG";
|
if (settingsLocation === "belowActivity") return firstChild === "CHANGELOG";
|
||||||
|
|
||||||
|
if (!header) return;
|
||||||
|
|
||||||
const names = {
|
const names = {
|
||||||
top: i18n.Messages.USER_SETTINGS,
|
top: i18n.Messages.USER_SETTINGS,
|
||||||
aboveNitro: i18n.Messages.BILLING_SETTINGS,
|
aboveNitro: i18n.Messages.BILLING_SETTINGS,
|
||||||
|
@ -163,12 +159,30 @@ export default definePlugin({
|
||||||
return header === names[settingsLocation];
|
return header === names[settingsLocation];
|
||||||
},
|
},
|
||||||
|
|
||||||
addSettings(elements: any[], element: { header?: string; settings: string[]; }, sectionTypes: Record<string, unknown>) {
|
patchedSettings: new WeakSet(),
|
||||||
if (!this.isRightSpot(element)) return;
|
|
||||||
|
addSettings(elements: any[], element: { header?: string; settings: string[]; }, sectionTypes: SectionTypes) {
|
||||||
|
if (this.patchedSettings.has(elements) || !this.isRightSpot(element)) return;
|
||||||
|
|
||||||
|
this.patchedSettings.add(elements);
|
||||||
|
|
||||||
elements.push(...this.makeSettingsCategories(sectionTypes));
|
elements.push(...this.makeSettingsCategories(sectionTypes));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
wrapSettingsHook(originalHook: (...args: any[]) => Record<string, unknown>[]) {
|
||||||
|
return (...args: any[]) => {
|
||||||
|
const elements = originalHook(...args);
|
||||||
|
if (!this.patchedSettings.has(elements))
|
||||||
|
elements.unshift(...this.makeSettingsCategories({
|
||||||
|
HEADER: "HEADER",
|
||||||
|
DIVIDER: "DIVIDER",
|
||||||
|
CUSTOM: "CUSTOM"
|
||||||
|
}));
|
||||||
|
|
||||||
|
return elements;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
settingsLocation: {
|
settingsLocation: {
|
||||||
type: OptionType.SELECT,
|
type: OptionType.SELECT,
|
||||||
|
@ -207,15 +221,24 @@ export default definePlugin({
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|
||||||
makeInfoElements(Component: React.ComponentType<React.PropsWithChildren>, props: React.PropsWithChildren) {
|
getInfoRows() {
|
||||||
const { electronVersion, chromiumVersion, additionalInfo } = this;
|
const { electronVersion, chromiumVersion, additionalInfo } = this;
|
||||||
|
|
||||||
return (
|
const rows = [`Vencord ${gitHash}${additionalInfo}`];
|
||||||
<>
|
|
||||||
<Component {...props}>Vencord {gitHash}{additionalInfo}</Component>
|
if (electronVersion) rows.push(`Electron ${electronVersion}`);
|
||||||
{electronVersion && <Component {...props}>Electron {electronVersion}</Component>}
|
if (chromiumVersion) rows.push(`Chromium ${chromiumVersion}`);
|
||||||
{chromiumVersion && <Component {...props}>Chromium {chromiumVersion}</Component>}
|
|
||||||
</>
|
return rows;
|
||||||
|
},
|
||||||
|
|
||||||
|
getInfoString() {
|
||||||
|
return "\n" + this.getInfoRows().join("\n");
|
||||||
|
},
|
||||||
|
|
||||||
|
makeInfoElements(Component: React.ComponentType<React.PropsWithChildren>, props: React.PropsWithChildren) {
|
||||||
|
return this.getInfoRows().map((text, i) =>
|
||||||
|
<Component key={i} {...props}>{text}</Component>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||||
import { FluxDispatcher, i18n } from "@webpack/common";
|
import { FluxDispatcher, i18n, useMemo } from "@webpack/common";
|
||||||
|
|
||||||
import FolderSideBar from "./FolderSideBar";
|
import FolderSideBar from "./FolderSideBar";
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
// If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders
|
// If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders
|
||||||
{
|
{
|
||||||
match: /(useStateFromStoresArray\).{0,25}let \i)=(\i\.\i.getGuildsTree\(\))/,
|
match: /\[(\i)\]=(\(0,\i\.useStateFromStoresArray\).{0,40}getGuildsTree\(\).+?}\))(?=,)/,
|
||||||
replace: (_, rest, guildsTree) => `${rest}=$self.getGuildTree(!!arguments[0].isBetterFolders,${guildsTree},arguments[0].betterFoldersExpandedIds)`
|
replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0].isBetterFolders,betterFoldersOriginalTree,arguments[0].betterFoldersExpandedIds)`
|
||||||
},
|
},
|
||||||
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
|
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
|
||||||
{
|
{
|
||||||
|
@ -252,19 +252,21 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getGuildTree(isBetterFolders: boolean, oldTree: any, expandedFolderIds?: Set<any>) {
|
getGuildTree(isBetterFolders: boolean, originalTree: any, expandedFolderIds?: Set<any>) {
|
||||||
if (!isBetterFolders || expandedFolderIds == null) return oldTree;
|
return useMemo(() => {
|
||||||
|
if (!isBetterFolders || expandedFolderIds == null) return originalTree;
|
||||||
|
|
||||||
const newTree = new GuildsTree();
|
const newTree = new GuildsTree();
|
||||||
// Children is every folder and guild which is not in a folder, this filters out only the expanded folders
|
// Children is every folder and guild which is not in a folder, this filters out only the expanded folders
|
||||||
newTree.root.children = oldTree.root.children.filter(guildOrFolder => expandedFolderIds.has(guildOrFolder.id));
|
newTree.root.children = originalTree.root.children.filter(guildOrFolder => expandedFolderIds.has(guildOrFolder.id));
|
||||||
// Nodes is every folder and guild, even if it's in a folder, this filters out only the expanded folders and guilds inside them
|
// Nodes is every folder and guild, even if it's in a folder, this filters out only the expanded folders and guilds inside them
|
||||||
newTree.nodes = Object.fromEntries(
|
newTree.nodes = Object.fromEntries(
|
||||||
Object.entries(oldTree.nodes)
|
Object.entries(originalTree.nodes)
|
||||||
.filter(([_, guildOrFolder]: any[]) => expandedFolderIds.has(guildOrFolder.id) || expandedFolderIds.has(guildOrFolder.parentId))
|
.filter(([_, guildOrFolder]: any[]) => expandedFolderIds.has(guildOrFolder.id) || expandedFolderIds.has(guildOrFolder.parentId))
|
||||||
);
|
);
|
||||||
|
|
||||||
return newTree;
|
return newTree;
|
||||||
|
}, [isBetterFolders, originalTree, expandedFolderIds]);
|
||||||
},
|
},
|
||||||
|
|
||||||
makeGuildsBarGuildListFilter(isBetterFolders: boolean) {
|
makeGuildsBarGuildListFilter(isBetterFolders: boolean) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ export default definePlugin({
|
||||||
{ // Settings cog context menu
|
{ // Settings cog context menu
|
||||||
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
|
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\(0,\i.default\)\(\)(?=\.filter\(\i=>\{let\{section:\i\}=)/,
|
match: /\(0,\i.useDefaultUserSettingsSections\)\(\)(?=\.filter\(\i=>\{let\{section:\i\}=)/,
|
||||||
replace: "$self.wrapMenu($&)"
|
replace: "$self.wrapMenu($&)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,22 +24,20 @@ import { closeAllModals } from "@utils/modal";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { maybePromptToUpdate } from "@utils/updater";
|
import { maybePromptToUpdate } from "@utils/updater";
|
||||||
import { filters, findBulk, proxyLazyWebpack } from "@webpack";
|
import { filters, findBulk, proxyLazyWebpack } from "@webpack";
|
||||||
import { FluxDispatcher, NavigationRouter, SelectedChannelStore } from "@webpack/common";
|
import { DraftType, FluxDispatcher, NavigationRouter, SelectedChannelStore } from "@webpack/common";
|
||||||
|
|
||||||
const CrashHandlerLogger = new Logger("CrashHandler");
|
const CrashHandlerLogger = new Logger("CrashHandler");
|
||||||
const { ModalStack, DraftManager, DraftType, closeExpressionPicker } = proxyLazyWebpack(() => {
|
|
||||||
const modules = findBulk(
|
const { ModalStack, DraftManager, closeExpressionPicker } = proxyLazyWebpack(() => {
|
||||||
|
const [ModalStack, DraftManager, ExpressionManager] = findBulk(
|
||||||
filters.byProps("pushLazy", "popAll"),
|
filters.byProps("pushLazy", "popAll"),
|
||||||
filters.byProps("clearDraft", "saveDraft"),
|
filters.byProps("clearDraft", "saveDraft"),
|
||||||
filters.byProps("DraftType"),
|
filters.byProps("closeExpressionPicker", "openExpressionPicker"),);
|
||||||
filters.byProps("closeExpressionPicker", "openExpressionPicker"),
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ModalStack: modules[0],
|
ModalStack,
|
||||||
DraftManager: modules[1],
|
DraftManager,
|
||||||
DraftType: modules[2]?.DraftType,
|
closeExpressionPicker: ExpressionManager?.closeExpressionPicker,
|
||||||
closeExpressionPicker: modules[3]?.closeExpressionPicker,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -137,8 +135,11 @@ export default definePlugin({
|
||||||
try {
|
try {
|
||||||
const channelId = SelectedChannelStore.getChannelId();
|
const channelId = SelectedChannelStore.getChannelId();
|
||||||
|
|
||||||
DraftManager.clearDraft(channelId, DraftType.ChannelMessage);
|
for (const key in DraftType) {
|
||||||
DraftManager.clearDraft(channelId, DraftType.FirstThreadMessage);
|
if (!Number.isNaN(Number(key))) continue;
|
||||||
|
|
||||||
|
DraftManager.clearDraft(channelId, DraftType[key]);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
CrashHandlerLogger.debug("Failed to clear drafts.", err);
|
CrashHandlerLogger.debug("Failed to clear drafts.", err);
|
||||||
}
|
}
|
||||||
|
|
68
src/plugins/ctrlEnterSend/index.ts
Normal file
68
src/plugins/ctrlEnterSend/index.ts
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "CtrlEnterSend",
|
||||||
|
authors: [Devs.UlyssesZhan],
|
||||||
|
description: "Use Ctrl+Enter to send messages (customizable)",
|
||||||
|
settings: definePluginSettings({
|
||||||
|
submitRule: {
|
||||||
|
description: "The way to send a message",
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "Ctrl+Enter (Enter or Shift+Enter for new line)",
|
||||||
|
value: "ctrl+enter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Shift+Enter (Enter for new line)",
|
||||||
|
value: "shift+enter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Enter (Shift+Enter for new line; Discord default)",
|
||||||
|
value: "enter"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
default: "ctrl+enter"
|
||||||
|
},
|
||||||
|
sendMessageInTheMiddleOfACodeBlock: {
|
||||||
|
description: "Whether to send a message in the middle of a code block",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: true,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: "KeyboardKeys.ENTER&&(!",
|
||||||
|
replacement: {
|
||||||
|
match: /(?<=(\i)\.which===\i\.KeyboardKeys.ENTER&&).{0,100}(\(0,\i\.hasOpenPlainTextCodeBlock\)\(\i\)).{0,100}(?=&&\(\i\.preventDefault)/,
|
||||||
|
replace: "$self.shouldSubmit($1, $2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
shouldSubmit(event: KeyboardEvent, codeblock: boolean): boolean {
|
||||||
|
let result = false;
|
||||||
|
switch (this.settings.store.submitRule) {
|
||||||
|
case "shift+enter":
|
||||||
|
result = event.shiftKey;
|
||||||
|
break;
|
||||||
|
case "ctrl+enter":
|
||||||
|
result = event.ctrlKey;
|
||||||
|
break;
|
||||||
|
case "enter":
|
||||||
|
result = !event.shiftKey && !event.ctrlKey;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!this.settings.store.sendMessageInTheMiddleOfACodeBlock) {
|
||||||
|
result &&= !codeblock;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
});
|
|
@ -24,13 +24,12 @@ import { getCurrentGuild } from "@utils/discord";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
|
import { findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
|
||||||
import { Alerts, ChannelStore, EmojiStore, FluxDispatcher, Forms, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
||||||
import type { CustomEmoji } from "@webpack/types";
|
import type { CustomEmoji } from "@webpack/types";
|
||||||
import type { Message } from "discord-types/general";
|
import type { Message } from "discord-types/general";
|
||||||
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
||||||
import type { ReactElement, ReactNode } from "react";
|
import type { ReactElement, ReactNode } from "react";
|
||||||
|
|
||||||
const DRAFT_TYPE = 0;
|
|
||||||
const StickerStore = findStoreLazy("StickersStore") as {
|
const StickerStore = findStoreLazy("StickersStore") as {
|
||||||
getPremiumPacks(): StickerPack[];
|
getPremiumPacks(): StickerPack[];
|
||||||
getAllGuildStickers(): Map<string, Sticker[]>;
|
getAllGuildStickers(): Map<string, Sticker[]>;
|
||||||
|
@ -807,7 +806,7 @@ export default definePlugin({
|
||||||
gif.finish();
|
gif.finish();
|
||||||
|
|
||||||
const file = new File([gif.bytesView()], `${stickerId}.gif`, { type: "image/gif" });
|
const file = new File([gif.bytesView()], `${stickerId}.gif`, { type: "image/gif" });
|
||||||
UploadHandler.promptToUpload([file], ChannelStore.getChannel(channelId), DRAFT_TYPE);
|
UploadHandler.promptToUpload([file], ChannelStore.getChannel(channelId), DraftType.ChannelMessage);
|
||||||
},
|
},
|
||||||
|
|
||||||
canUseEmote(e: CustomEmoji, channelId: string) {
|
canUseEmote(e: CustomEmoji, channelId: string) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ interface TagSettings {
|
||||||
MODERATOR_STAFF: TagSetting,
|
MODERATOR_STAFF: TagSetting,
|
||||||
MODERATOR: TagSetting,
|
MODERATOR: TagSetting,
|
||||||
VOICE_MODERATOR: TagSetting,
|
VOICE_MODERATOR: TagSetting,
|
||||||
|
TRIAL_MODERATOR: TagSetting,
|
||||||
[k: string]: TagSetting;
|
[k: string]: TagSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +94,11 @@ const tags: Tag[] = [
|
||||||
displayName: "VC Mod",
|
displayName: "VC Mod",
|
||||||
description: "Can manage voice chats",
|
description: "Can manage voice chats",
|
||||||
permissions: ["MOVE_MEMBERS", "MUTE_MEMBERS", "DEAFEN_MEMBERS"]
|
permissions: ["MOVE_MEMBERS", "MUTE_MEMBERS", "DEAFEN_MEMBERS"]
|
||||||
|
}, {
|
||||||
|
name: "CHAT_MODERATOR",
|
||||||
|
displayName: "Chat Mod",
|
||||||
|
description: "Can timeout people",
|
||||||
|
permissions: ["MODERATE_MEMBERS"]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const defaultSettings = Object.fromEntries(
|
const defaultSettings = Object.fromEntries(
|
||||||
|
@ -263,34 +269,14 @@ export default definePlugin({
|
||||||
],
|
],
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if (settings.store.tagSettings) return;
|
settings.store.tagSettings ??= defaultSettings;
|
||||||
// @ts-ignore
|
|
||||||
if (!settings.store.visibility_WEBHOOK) settings.store.tagSettings = defaultSettings;
|
// newly added field might be missing from old users
|
||||||
else {
|
settings.store.tagSettings.CHAT_MODERATOR ??= {
|
||||||
const newSettings = { ...defaultSettings };
|
text: "Chat Mod",
|
||||||
Object.entries(Vencord.PlainSettings.plugins.MoreUserTags).forEach(([name, value]) => {
|
showInChat: true,
|
||||||
const [setting, tag] = name.split("_");
|
showInNotChat: true
|
||||||
if (setting === "visibility") {
|
};
|
||||||
switch (value) {
|
|
||||||
case "always":
|
|
||||||
// its the default
|
|
||||||
break;
|
|
||||||
case "chat":
|
|
||||||
newSettings[tag].showInNotChat = false;
|
|
||||||
break;
|
|
||||||
case "not-chat":
|
|
||||||
newSettings[tag].showInChat = false;
|
|
||||||
break;
|
|
||||||
case "never":
|
|
||||||
newSettings[tag].showInChat = false;
|
|
||||||
newSettings[tag].showInNotChat = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
settings.store.tagSettings = newSettings;
|
|
||||||
delete Vencord.Settings.plugins.MoreUserTags[name];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getPermissions(user: User, channel: Channel): string[] {
|
getPermissions(user: User, channel: Channel): string[] {
|
||||||
|
|
50
src/plugins/noServerEmojis/index.ts
Normal file
50
src/plugins/noServerEmojis/index.ts
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
shownEmojis: {
|
||||||
|
description: "The types of emojis to show in the autocomplete menu.",
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
default: "onlyUnicode",
|
||||||
|
options: [
|
||||||
|
{ label: "Only unicode emojis", value: "onlyUnicode" },
|
||||||
|
{ label: "Unicode emojis and server emojis from current server", value: "currentServer" },
|
||||||
|
{ label: "Unicode emojis and all server emojis (Discord default)", value: "all" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "NoServerEmojis",
|
||||||
|
authors: [Devs.UlyssesZhan],
|
||||||
|
description: "Do not show server emojis in the autocomplete menu.",
|
||||||
|
settings,
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: "}searchWithoutFetchingLatest(",
|
||||||
|
replacement: {
|
||||||
|
match: /searchWithoutFetchingLatest.{20,300}get\((\i).{10,40}?reduce\(\((\i),(\i)\)=>\{/,
|
||||||
|
replace: "$& if ($self.shouldSkip($1, $3)) return $2;"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
shouldSkip(guildId: string, emoji: any) {
|
||||||
|
if (emoji.type !== "GUILD_EMOJI") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (settings.store.shownEmojis === "onlyUnicode") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (settings.store.shownEmojis === "currentServer") {
|
||||||
|
return emoji.guildId !== guildId;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
|
@ -26,6 +26,7 @@ const ShortUrlMatcher = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
|
||||||
const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user|episode)\/(.+)(?:\?.+?)?$/;
|
const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user|episode)\/(.+)(?:\?.+?)?$/;
|
||||||
const SteamMatcher = /^https:\/\/(steamcommunity\.com|(?:help|store)\.steampowered\.com)\/.+$/;
|
const SteamMatcher = /^https:\/\/(steamcommunity\.com|(?:help|store)\.steampowered\.com)\/.+$/;
|
||||||
const EpicMatcher = /^https:\/\/store\.epicgames\.com\/(.+)$/;
|
const EpicMatcher = /^https:\/\/store\.epicgames\.com\/(.+)$/;
|
||||||
|
const TidalMatcher = /^https:\/\/tidal\.com\/browse\/(track|album|artist|playlist|user|video|mix)\/(.+)(?:\?.+?)?$/;
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
spotify: {
|
spotify: {
|
||||||
|
@ -42,6 +43,11 @@ const settings = definePluginSettings({
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Open Epic Games links in the Epic Games Launcher",
|
description: "Open Epic Games links in the Epic Games Launcher",
|
||||||
default: true,
|
default: true,
|
||||||
|
},
|
||||||
|
tidal: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Open Tidal links in the Tidal app",
|
||||||
|
default: true,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -49,7 +55,7 @@ const Native = VencordNative.pluginHelpers.OpenInApp as PluginNative<typeof impo
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "OpenInApp",
|
name: "OpenInApp",
|
||||||
description: "Open Spotify, Steam and Epic Games URLs in their respective apps instead of your browser",
|
description: "Open Spotify, Tidal, Steam and Epic Games URLs in their respective apps instead of your browser",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
@ -127,6 +133,19 @@ export default definePlugin({
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tidal: {
|
||||||
|
if (!settings.store.tidal) break tidal;
|
||||||
|
|
||||||
|
const match = TidalMatcher.exec(url);
|
||||||
|
if (!match) break tidal;
|
||||||
|
|
||||||
|
const [, type, id] = match;
|
||||||
|
VencordNative.native.openExternal(`tidal://${type}/${id}`);
|
||||||
|
|
||||||
|
event?.preventDefault();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// in case short url didn't end up being something we can handle
|
// in case short url didn't end up being something we can handle
|
||||||
if (event?.defaultPrevented) {
|
if (event?.defaultPrevented) {
|
||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
|
|
|
@ -21,10 +21,9 @@ import { Devs } from "@utils/constants";
|
||||||
import { makeLazy } from "@utils/lazy";
|
import { makeLazy } from "@utils/lazy";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { UploadHandler, UserUtils } from "@webpack/common";
|
import { DraftType, UploadHandler, UploadManager, UserUtils } from "@webpack/common";
|
||||||
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
||||||
|
|
||||||
const DRAFT_TYPE = 0;
|
|
||||||
const DEFAULT_DELAY = 20;
|
const DEFAULT_DELAY = 20;
|
||||||
const DEFAULT_RESOLUTION = 128;
|
const DEFAULT_RESOLUTION = 128;
|
||||||
const FRAMES = 10;
|
const FRAMES = 10;
|
||||||
|
@ -59,9 +58,12 @@ async function resolveImage(options: Argument[], ctx: CommandContext, noServerPf
|
||||||
for (const opt of options) {
|
for (const opt of options) {
|
||||||
switch (opt.name) {
|
switch (opt.name) {
|
||||||
case "image":
|
case "image":
|
||||||
const upload = UploadStore.getUploads(ctx.channel.id, DRAFT_TYPE)[0];
|
const upload = UploadStore.getUpload(ctx.channel.id, opt.name, DraftType.SlashCommand);
|
||||||
if (upload) {
|
if (upload) {
|
||||||
if (!upload.isImage) throw "Upload is not an image";
|
if (!upload.isImage) {
|
||||||
|
UploadManager.clearAll(ctx.channel.id, DraftType.SlashCommand);
|
||||||
|
throw "Upload is not an image";
|
||||||
|
}
|
||||||
return upload.item.file;
|
return upload.item.file;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -73,10 +75,12 @@ async function resolveImage(options: Argument[], ctx: CommandContext, noServerPf
|
||||||
return user.getAvatarURL(noServerPfp ? void 0 : ctx.guild?.id, 2048).replace(/\?size=\d+$/, "?size=2048");
|
return user.getAvatarURL(noServerPfp ? void 0 : ctx.guild?.id, 2048).replace(/\?size=\d+$/, "?size=2048");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[petpet] Failed to fetch user\n", err);
|
console.error("[petpet] Failed to fetch user\n", err);
|
||||||
|
UploadManager.clearAll(ctx.channel.id, DraftType.SlashCommand);
|
||||||
throw "Failed to fetch user. Check the console for more info.";
|
throw "Failed to fetch user. Check the console for more info.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UploadManager.clearAll(ctx.channel.id, DraftType.SlashCommand);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +134,7 @@ export default definePlugin({
|
||||||
var url = await resolveImage(opts, cmdCtx, noServerPfp);
|
var url = await resolveImage(opts, cmdCtx, noServerPfp);
|
||||||
if (!url) throw "No Image specified!";
|
if (!url) throw "No Image specified!";
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
UploadManager.clearAll(cmdCtx.channel.id, DraftType.SlashCommand);
|
||||||
sendBotMessage(cmdCtx.channel.id, {
|
sendBotMessage(cmdCtx.channel.id, {
|
||||||
content: String(err),
|
content: String(err),
|
||||||
});
|
});
|
||||||
|
@ -147,6 +152,8 @@ export default definePlugin({
|
||||||
canvas.width = canvas.height = resolution;
|
canvas.width = canvas.height = resolution;
|
||||||
const ctx = canvas.getContext("2d")!;
|
const ctx = canvas.getContext("2d")!;
|
||||||
|
|
||||||
|
UploadManager.clearAll(cmdCtx.channel.id, DraftType.SlashCommand);
|
||||||
|
|
||||||
for (let i = 0; i < FRAMES; i++) {
|
for (let i = 0; i < FRAMES; i++) {
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
@ -174,7 +181,7 @@ export default definePlugin({
|
||||||
const file = new File([gif.bytesView()], "petpet.gif", { type: "image/gif" });
|
const file = new File([gif.bytesView()], "petpet.gif", { type: "image/gif" });
|
||||||
// Immediately after the command finishes, Discord clears all input, including pending attachments.
|
// Immediately after the command finishes, Discord clears all input, including pending attachments.
|
||||||
// Thus, setTimeout is needed to make this execute after Discord cleared the input
|
// Thus, setTimeout is needed to make this execute after Discord cleared the input
|
||||||
setTimeout(() => UploadHandler.promptToUpload([file], cmdCtx.channel, DRAFT_TYPE), 10);
|
setTimeout(() => UploadHandler.promptToUpload([file], cmdCtx.channel, DraftType.ChannelMessage), 10);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -26,10 +26,12 @@ export default definePlugin({
|
||||||
description: "Adds Startup Timings to the Settings menu",
|
description: "Adds Startup Timings to the Settings menu",
|
||||||
authors: [Devs.Megu],
|
authors: [Devs.Megu],
|
||||||
patches: [{
|
patches: [{
|
||||||
find: "UserSettingsSections.PAYMENT_FLOW_MODAL_TEST_PAGE,",
|
find: "Messages.ACTIVITY_SETTINGS",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /{section:\i\.UserSettingsSections\.PAYMENT_FLOW_MODAL_TEST_PAGE/,
|
match: /(?<=}\)([,;])(\i\.settings)\.forEach.+?(\i)\.push.+}\))/,
|
||||||
replace: '{section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage},$&'
|
replace: (_, commaOrSemi, settings, elements) => "" +
|
||||||
|
`${commaOrSemi}${settings}?.[0]==="CHANGELOG"` +
|
||||||
|
`&&${elements}.push({section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage})`
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
StartupTimingPage
|
StartupTimingPage
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# ThemeAttributes
|
# ThemeAttributes
|
||||||
|
|
||||||
This plugin adds data attributes to various elements inside Discord
|
This plugin adds data attributes and CSS variables to various elements inside Discord
|
||||||
|
|
||||||
This allows themes to more easily theme those elements or even do things that otherwise wouldn't be possible
|
This allows themes to more easily theme those elements or even do things that otherwise wouldn't be possible
|
||||||
|
|
||||||
|
@ -19,3 +19,11 @@ This allows themes to more easily theme those elements or even do things that ot
|
||||||
- `data-is-self` is a boolean indicating whether this is the current user's message
|
- `data-is-self` is a boolean indicating whether this is the current user's message
|
||||||
|
|
||||||
![image](https://github.com/Vendicated/Vencord/assets/45497981/34bd5053-3381-402f-82b2-9c812cc7e122)
|
![image](https://github.com/Vendicated/Vencord/assets/45497981/34bd5053-3381-402f-82b2-9c812cc7e122)
|
||||||
|
|
||||||
|
## CSS Variables
|
||||||
|
|
||||||
|
### Avatars
|
||||||
|
|
||||||
|
`--avatar-url-<resolution>` contains a URL for the users avatar with the size attribute adjusted for the resolutions `128, 256, 512, 1024, 2048, 4096`.
|
||||||
|
|
||||||
|
![image](https://github.com/Vendicated/Vencord/assets/26598490/192ddac0-c827-472f-9933-fa99ff36f723)
|
||||||
|
|
|
@ -9,10 +9,11 @@ import definePlugin from "@utils/types";
|
||||||
import { UserStore } from "@webpack/common";
|
import { UserStore } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ThemeAttributes",
|
name: "ThemeAttributes",
|
||||||
description: "Adds data attributes to various elements for theming purposes",
|
description: "Adds data attributes to various elements for theming purposes",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven, Devs.Board],
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
// Add data-tab-id to all tab bar items
|
// Add data-tab-id to all tab bar items
|
||||||
|
@ -32,9 +33,36 @@ export default definePlugin({
|
||||||
match: /\.messageListItem(?=,"aria)/,
|
match: /\.messageListItem(?=,"aria)/,
|
||||||
replace: "$&,...$self.getMessageProps(arguments[0])"
|
replace: "$&,...$self.getMessageProps(arguments[0])"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// add --avatar-url-<resolution> css variable to avatar img elements
|
||||||
|
// popout profiles
|
||||||
|
{
|
||||||
|
find: ".LABEL_WITH_ONLINE_STATUS",
|
||||||
|
replacement: {
|
||||||
|
match: /src:null!=\i\?(\i).{1,50}"aria-hidden":!0/,
|
||||||
|
replace: "$&,style:$self.getAvatarStyles($1)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// chat avatars
|
||||||
|
{
|
||||||
|
find: "showCommunicationDisabledStyles",
|
||||||
|
replacement: {
|
||||||
|
match: /src:(\i),"aria-hidden":!0/,
|
||||||
|
replace: "$&,style:$self.getAvatarStyles($1)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
getAvatarStyles(src: string) {
|
||||||
|
return Object.fromEntries(
|
||||||
|
[128, 256, 512, 1024, 2048, 4096].map(size => [
|
||||||
|
`--avatar-url-${size}`,
|
||||||
|
`url(${src.replace(/\d+$/, String(size))})`
|
||||||
|
])
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
getMessageProps(props: { message: Message; }) {
|
getMessageProps(props: { message: Message; }) {
|
||||||
const author = props.message?.author;
|
const author = props.message?.author;
|
||||||
const authorId = author?.id;
|
const authorId = author?.id;
|
||||||
|
|
7
src/plugins/validReply/README.md
Normal file
7
src/plugins/validReply/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# ValidReply
|
||||||
|
|
||||||
|
Fixes referenced (replied to) messages showing as "Message could not be loaded".
|
||||||
|
|
||||||
|
Hover the text to load the message!
|
||||||
|
|
||||||
|
![](https://github.com/Vendicated/Vencord/assets/45801973/d3286acf-e822-4b7f-a4e7-8ced18f581af)
|
106
src/plugins/validReply/index.ts
Normal file
106
src/plugins/validReply/index.ts
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
import { FluxDispatcher, RestAPI } from "@webpack/common";
|
||||||
|
import { Message, User } from "discord-types/general";
|
||||||
|
import { Channel } from "discord-types/general/index.js";
|
||||||
|
|
||||||
|
const enum ReferencedMessageState {
|
||||||
|
Loaded,
|
||||||
|
NotLoaded,
|
||||||
|
Deleted
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Reply {
|
||||||
|
baseAuthor: User,
|
||||||
|
baseMessage: Message;
|
||||||
|
channel: Channel;
|
||||||
|
referencedMessage: { state: ReferencedMessageState; };
|
||||||
|
compact: boolean;
|
||||||
|
isReplyAuthorBlocked: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetching = new Map<string, string>();
|
||||||
|
let ReplyStore: any;
|
||||||
|
|
||||||
|
const { createMessageRecord } = findByPropsLazy("createMessageRecord");
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "ValidReply",
|
||||||
|
description: 'Fixes "Message could not be loaded" upon hovering over the reply',
|
||||||
|
authors: [Devs.newwares],
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: "Messages.REPLY_QUOTE_MESSAGE_NOT_LOADED",
|
||||||
|
replacement: {
|
||||||
|
match: /Messages\.REPLY_QUOTE_MESSAGE_NOT_LOADED/,
|
||||||
|
replace: "$&,onMouseEnter:()=>$self.fetchReply(arguments[0])"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: "ReferencedMessageStore",
|
||||||
|
replacement: {
|
||||||
|
match: /constructor\(\)\{\i\(this,"_channelCaches",new Map\)/,
|
||||||
|
replace: "$&;$self.setReplyStore(this);"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
setReplyStore(store: any) {
|
||||||
|
ReplyStore = store;
|
||||||
|
},
|
||||||
|
|
||||||
|
async fetchReply(reply: Reply) {
|
||||||
|
const { channel_id: channelId, message_id: messageId } = reply.baseMessage.messageReference!;
|
||||||
|
|
||||||
|
if (fetching.has(messageId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fetching.set(messageId, channelId);
|
||||||
|
|
||||||
|
RestAPI.get({
|
||||||
|
url: `/channels/${channelId}/messages`,
|
||||||
|
query: {
|
||||||
|
limit: 1,
|
||||||
|
around: messageId
|
||||||
|
},
|
||||||
|
retries: 2
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
const reply: Message | undefined = res?.body?.[0];
|
||||||
|
if (!reply) return;
|
||||||
|
|
||||||
|
if (reply.id !== messageId) {
|
||||||
|
ReplyStore.set(channelId, messageId, {
|
||||||
|
state: ReferencedMessageState.Deleted
|
||||||
|
});
|
||||||
|
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "MESSAGE_DELETE",
|
||||||
|
channelId: channelId,
|
||||||
|
message: messageId
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ReplyStore.set(reply.channel_id, reply.id, {
|
||||||
|
state: ReferencedMessageState.Loaded,
|
||||||
|
message: createMessageRecord(reply)
|
||||||
|
});
|
||||||
|
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "MESSAGE_UPDATE",
|
||||||
|
message: reply
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => { })
|
||||||
|
.finally(() => {
|
||||||
|
fetching.delete(messageId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -378,10 +378,18 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "ProffDea",
|
name: "ProffDea",
|
||||||
id: 609329952180928513n
|
id: 609329952180928513n
|
||||||
},
|
},
|
||||||
|
UlyssesZhan: {
|
||||||
|
name: "UlyssesZhan",
|
||||||
|
id: 586808226058862623n
|
||||||
|
},
|
||||||
ant0n: {
|
ant0n: {
|
||||||
name: "ant0n",
|
name: "ant0n",
|
||||||
id: 145224646868860928n
|
id: 145224646868860928n
|
||||||
},
|
},
|
||||||
|
Board: {
|
||||||
|
name: "BoardTM",
|
||||||
|
id: 285475344817848320n,
|
||||||
|
},
|
||||||
philipbry: {
|
philipbry: {
|
||||||
name: "philipbry",
|
name: "philipbry",
|
||||||
id: 554994003318276106n
|
id: 554994003318276106n
|
||||||
|
@ -477,7 +485,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
xocherry: {
|
xocherry: {
|
||||||
name: "xocherry",
|
name: "xocherry",
|
||||||
id: 221288171013406720n
|
id: 221288171013406720n
|
||||||
}
|
},
|
||||||
|
ScattrdBlade: {
|
||||||
|
name: "ScattrdBlade",
|
||||||
|
id: 678007540608532491n
|
||||||
|
},
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
// iife so #__PURE__ works correctly
|
// iife so #__PURE__ works correctly
|
||||||
|
|
|
@ -29,14 +29,19 @@ export default function definePlugin<P extends PluginDef>(p: P & Record<string,
|
||||||
export type ReplaceFn = (match: string, ...groups: string[]) => string;
|
export type ReplaceFn = (match: string, ...groups: string[]) => string;
|
||||||
|
|
||||||
export interface PatchReplacement {
|
export interface PatchReplacement {
|
||||||
|
/** The match for the patch replacement. If you use a string it will be implicitly converted to a RegExp */
|
||||||
match: string | RegExp;
|
match: string | RegExp;
|
||||||
|
/** The replacement string or function which returns the string for the patch replacement */
|
||||||
replace: string | ReplaceFn;
|
replace: string | ReplaceFn;
|
||||||
|
/** A function which returns whether this patch replacement should be applied */
|
||||||
predicate?(): boolean;
|
predicate?(): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Patch {
|
export interface Patch {
|
||||||
plugin: string;
|
plugin: string;
|
||||||
find: string;
|
/** A string or RegExp which is only include/matched in the module code you wish to patch. Prefer only using a RegExp if a simple string test is not enough */
|
||||||
|
find: string | RegExp;
|
||||||
|
/** The replacement(s) for the module being patched */
|
||||||
replacement: PatchReplacement | PatchReplacement[];
|
replacement: PatchReplacement | PatchReplacement[];
|
||||||
/** Whether this patch should apply to multiple modules */
|
/** Whether this patch should apply to multiple modules */
|
||||||
all?: boolean;
|
all?: boolean;
|
||||||
|
@ -44,6 +49,7 @@ export interface Patch {
|
||||||
noWarn?: boolean;
|
noWarn?: boolean;
|
||||||
/** Only apply this set of replacements if all of them succeed. Use this if your replacements depend on each other */
|
/** Only apply this set of replacements if all of them succeed. Use this if your replacements depend on each other */
|
||||||
group?: boolean;
|
group?: boolean;
|
||||||
|
/** A function which returns whether this patch should be applied */
|
||||||
predicate?(): boolean;
|
predicate?(): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,7 @@ export const Flux: t.Flux = findByPropsLazy("connectStores");
|
||||||
|
|
||||||
export type GenericStore = t.FluxStore & Record<string, any>;
|
export type GenericStore = t.FluxStore & Record<string, any>;
|
||||||
|
|
||||||
export enum DraftType {
|
export const { DraftType }: { DraftType: typeof t.DraftType; } = findByPropsLazy("DraftType");
|
||||||
ChannelMessage = 0,
|
|
||||||
ThreadSettings = 1,
|
|
||||||
FirstThreadMessage = 2,
|
|
||||||
ApplicationLauncherCommand = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
export let MessageStore: Omit<Stores.MessageStore, "getMessages"> & {
|
export let MessageStore: Omit<Stores.MessageStore, "getMessages"> & {
|
||||||
getMessages(chanId: string): any;
|
getMessages(chanId: string): any;
|
||||||
|
|
9
src/webpack/common/types/stores.d.ts
vendored
9
src/webpack/common/types/stores.d.ts
vendored
|
@ -173,6 +173,15 @@ export class DraftStore extends FluxStore {
|
||||||
getThreadSettings(channelId: string): any | null;
|
getThreadSettings(channelId: string): any | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum DraftType {
|
||||||
|
ChannelMessage,
|
||||||
|
ThreadSettings,
|
||||||
|
FirstThreadMessage,
|
||||||
|
ApplicationLauncherCommand,
|
||||||
|
Poll,
|
||||||
|
SlashCommand,
|
||||||
|
}
|
||||||
|
|
||||||
export class GuildStore extends FluxStore {
|
export class GuildStore extends FluxStore {
|
||||||
getGuild(guildId: string): Guild;
|
getGuild(guildId: string): Guild;
|
||||||
getGuildCount(): number;
|
getGuildCount(): number;
|
||||||
|
|
|
@ -119,6 +119,8 @@ export function showToast(message: string, type = ToastType.MESSAGE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UserUtils = findByPropsLazy("getUser", "fetchCurrentUser") as { getUser: (id: string) => Promise<User>; };
|
export const UserUtils = findByPropsLazy("getUser", "fetchCurrentUser") as { getUser: (id: string) => Promise<User>; };
|
||||||
|
|
||||||
|
export const UploadManager = findByPropsLazy("clearAll", "addFile");
|
||||||
export const UploadHandler = findByPropsLazy("showUploadFileSizeExceededError", "promptToUpload") as {
|
export const UploadHandler = findByPropsLazy("showUploadFileSizeExceededError", "promptToUpload") as {
|
||||||
promptToUpload: (files: File[], channel: Channel, draftType: Number) => void;
|
promptToUpload: (files: File[], channel: Channel, draftType: Number) => void;
|
||||||
};
|
};
|
||||||
|
|
|
@ -257,7 +257,12 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
|
||||||
for (let i = 0; i < patches.length; i++) {
|
for (let i = 0; i < patches.length; i++) {
|
||||||
const patch = patches[i];
|
const patch = patches[i];
|
||||||
if (patch.predicate && !patch.predicate()) continue;
|
if (patch.predicate && !patch.predicate()) continue;
|
||||||
if (!code.includes(patch.find)) continue;
|
|
||||||
|
const moduleMatches = typeof patch.find === "string"
|
||||||
|
? code.includes(patch.find)
|
||||||
|
: patch.find.test(code);
|
||||||
|
|
||||||
|
if (!moduleMatches) continue;
|
||||||
|
|
||||||
patchedBy.add(patch.plugin);
|
patchedBy.add(patch.plugin);
|
||||||
|
|
||||||
|
|
|
@ -432,7 +432,7 @@ export async function extractAndLoadChunks(code: string[], matcher: RegExp = Def
|
||||||
}
|
}
|
||||||
|
|
||||||
const [, rawChunkIds, entryPointId] = match;
|
const [, rawChunkIds, entryPointId] = match;
|
||||||
if (Number.isNaN(entryPointId)) {
|
if (Number.isNaN(Number(entryPointId))) {
|
||||||
const err = new Error("extractAndLoadChunks: Matcher didn't return a capturing group with the chunk ids array, or the entry point id returned as the second group wasn't a number");
|
const err = new Error("extractAndLoadChunks: Matcher didn't return a capturing group with the chunk ids array, or the entry point id returned as the second group wasn't a number");
|
||||||
logger.warn(err, "Code:", code, "Matcher:", matcher);
|
logger.warn(err, "Code:", code, "Matcher:", matcher);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue