Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3c02d6e1b4 | ||
|
a2a33ca62d | ||
|
d8cd557fb2 | ||
|
7568bbaed0 | ||
|
9023d45d9e | ||
|
bee70390a9 | ||
|
3e3d05fc26 | ||
|
6300198a54 | ||
|
458c7ed4c5 | ||
|
d888a0a291 | ||
|
a94787a9f3 | ||
|
368d2bcdbb | ||
|
bc46bfa467 | ||
|
dab48288a8 | ||
|
9aef97c771 | ||
|
9d62dec6b9 | ||
|
6bf6583e7d | ||
|
5219fb700f | ||
|
184c03b28e | ||
|
ec091a7959 | ||
|
89a6c575c9 | ||
|
60325c6aa5 | ||
|
c2a1c4cbf6 | ||
|
1d6b78f6c6 | ||
|
341151a718 | ||
|
f6fd7cf37a | ||
|
d53476a32a | ||
|
fc943b7778 | ||
|
3f2bcd2cab | ||
|
235000cf41 | ||
|
263884cbd8 | ||
|
bb83c0b672 | ||
|
2815509c00 |
18
.github/workflows/codeberg-mirror.yml
vendored
Normal file
18
.github/workflows/codeberg-mirror.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: Sync to Codeberg
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 */6 * * *"
|
||||
|
||||
jobs:
|
||||
codeberg:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: pixta-dev/repository-mirroring-action@674e65a7d483ca28dafaacba0d07351bdcc8bd75 # v1.1.1
|
||||
with:
|
||||
target_repo_url: "git@codeberg.org:Ven/cord.git"
|
||||
ssh_private_key: ${{ secrets.CODEBERG_SSH_PRIVATE_KEY }}
|
@ -57,7 +57,7 @@ Discord is trademark of Discord Inc. and solely mentioned for the sake of descri
|
||||
Mention of it does not imply any affiliation with or endorsement by Discord Inc.
|
||||
|
||||
<details>
|
||||
<summary>Using Vencord violates Discord's terms of service</summary>
|
||||
<summary>Using Vencord violates Discord's terms of service</summary>
|
||||
|
||||
Client modifications are against Discord’s Terms of Service.
|
||||
|
||||
|
@ -16,20 +16,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function fetchOptions(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const opt = {
|
||||
method: "OPTIONS",
|
||||
url: url,
|
||||
};
|
||||
opt.onload = resp => resolve(resp.responseHeaders);
|
||||
opt.ontimeout = () => reject("fetch timeout");
|
||||
opt.onerror = () => reject("fetch error");
|
||||
opt.onabort = () => reject("fetch abort");
|
||||
GM_xmlhttpRequest(opt);
|
||||
});
|
||||
}
|
||||
|
||||
function parseHeaders(headers) {
|
||||
if (!headers)
|
||||
return {};
|
||||
@ -52,21 +38,6 @@ function parseHeaders(headers) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// returns true if CORS permits request
|
||||
async function checkCors(url, method) {
|
||||
const headers = parseHeaders(await fetchOptions(url));
|
||||
|
||||
const origin = headers["access-control-allow-origin"];
|
||||
if (origin !== "*" && origin !== window.location.origin) return false;
|
||||
|
||||
const methods = headers["access-control-allow-methods"]?.toLowerCase()
|
||||
.split(",")
|
||||
.map(s => s.trim());
|
||||
if (methods && !methods.includes(method.toLowerCase())) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function blobTo(to, blob) {
|
||||
if (to === "arrayBuffer" && blob.arrayBuffer) return blob.arrayBuffer();
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -80,31 +51,25 @@ function blobTo(to, blob) {
|
||||
|
||||
function GM_fetch(url, opt) {
|
||||
return new Promise((resolve, reject) => {
|
||||
checkCors(url, opt?.method || "GET")
|
||||
.then(can => {
|
||||
if (can) {
|
||||
// https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest
|
||||
const options = opt || {};
|
||||
options.url = url;
|
||||
options.data = options.body;
|
||||
options.responseType = "blob";
|
||||
options.onload = resp => {
|
||||
var blob = resp.response;
|
||||
resp.blob = () => Promise.resolve(blob);
|
||||
resp.arrayBuffer = () => blobTo("arrayBuffer", blob);
|
||||
resp.text = () => blobTo("text", blob);
|
||||
resp.json = async () => JSON.parse(await blobTo("text", blob));
|
||||
resp.headers = new Headers(parseHeaders(resp.responseHeaders));
|
||||
resolve(resp);
|
||||
};
|
||||
options.ontimeout = () => reject("fetch timeout");
|
||||
options.onerror = () => reject("fetch error");
|
||||
options.onabort = () => reject("fetch abort");
|
||||
GM_xmlhttpRequest(options);
|
||||
} else {
|
||||
reject("CORS issue");
|
||||
}
|
||||
});
|
||||
// https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest
|
||||
const options = opt || {};
|
||||
options.url = url;
|
||||
options.data = options.body;
|
||||
options.responseType = "blob";
|
||||
options.onload = resp => {
|
||||
var blob = resp.response;
|
||||
resp.blob = () => Promise.resolve(blob);
|
||||
resp.arrayBuffer = () => blobTo("arrayBuffer", blob);
|
||||
resp.text = () => blobTo("text", blob);
|
||||
resp.json = async () => JSON.parse(await blobTo("text", blob));
|
||||
resp.headers = new Headers(parseHeaders(resp.responseHeaders));
|
||||
resp.ok = resp.status >= 200 && resp.status < 300;
|
||||
resolve(resp);
|
||||
};
|
||||
options.ontimeout = () => reject("fetch timeout");
|
||||
options.onerror = () => reject("fetch error");
|
||||
options.onabort = () => reject("fetch abort");
|
||||
GM_xmlhttpRequest(options);
|
||||
});
|
||||
}
|
||||
export const fetch = GM_fetch;
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vencord",
|
||||
"private": "true",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.6",
|
||||
"description": "The cutest Discord client mod",
|
||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||
"bugs": {
|
||||
|
@ -16,6 +16,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "../checkNodeVersion.js";
|
||||
|
||||
import { exec, execSync } from "child_process";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
import { readdir, readFile } from "fs/promises";
|
||||
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2022 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// A script to automatically generate a list of all plugins.
|
||||
// Just copy paste the entire file into a running Vencord install and it will prompt you
|
||||
// to save the file
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="../src/modules"/>
|
||||
|
||||
(() => {
|
||||
/**
|
||||
* @type {typeof import("~plugins").default}
|
||||
*/
|
||||
const Plugins = Vencord.Plugins.plugins;
|
||||
|
||||
const header = `
|
||||
<!-- This file is auto generated, do not edit -->
|
||||
|
||||
# Vencord Plugins
|
||||
`;
|
||||
|
||||
let tableOfContents = "\n\n";
|
||||
|
||||
let list = "\n\n";
|
||||
|
||||
for (const p of Object.values(Plugins).sort((a, b) => a.name.localeCompare(b.name))) {
|
||||
tableOfContents += `- [${p.name}](#${p.name.replaceAll(" ", "-")})\n`;
|
||||
|
||||
list += `## ${p.name}
|
||||
|
||||
${p.description}
|
||||
|
||||
**Authors**: ${p.authors.map(a => a.name).join(", ")}
|
||||
`;
|
||||
|
||||
if (p.commands?.length) {
|
||||
list += "\n\n#### Commands\n";
|
||||
for (const cmd of p.commands) {
|
||||
list += `${cmd.name} - ${cmd.description}\n\n`;
|
||||
}
|
||||
}
|
||||
list += "\n\n";
|
||||
}
|
||||
|
||||
copy(header + tableOfContents + list);
|
||||
})();
|
@ -19,7 +19,7 @@
|
||||
import { Dirent, readdirSync, readFileSync, writeFileSync } from "fs";
|
||||
import { access, readFile } from "fs/promises";
|
||||
import { join } from "path";
|
||||
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
||||
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
||||
|
||||
interface Dev {
|
||||
name: string;
|
||||
@ -66,9 +66,9 @@ function parseDevs() {
|
||||
|
||||
const value = devsDeclaration.initializer.arguments[0];
|
||||
|
||||
if (!isObjectLiteralExpression(value)) return;
|
||||
if (!isSatisfiesExpression(value) || !isObjectLiteralExpression(value.expression)) throw new Error("Failed to parse devs: not an object literal");
|
||||
|
||||
for (const prop of value.properties) {
|
||||
for (const prop of value.expression.properties) {
|
||||
const name = (prop.name as Identifier).text;
|
||||
const value = isPropertyAssignment(prop) ? prop.initializer : prop;
|
||||
|
||||
@ -130,7 +130,9 @@ async function parseFile(fileName: string) {
|
||||
if (!isArrayLiteralExpression(value)) throw fail("authors is not an array literal");
|
||||
data.authors = value.elements.map(e => {
|
||||
if (!isPropertyAccessExpression(e)) throw fail("authors array contains non-property access expressions");
|
||||
return devs[getName(e)!];
|
||||
const d = devs[getName(e)!];
|
||||
if (!d) throw fail(`couldn't look up author ${getName(e)}`);
|
||||
return d;
|
||||
});
|
||||
break;
|
||||
case "tags":
|
||||
|
@ -25,14 +25,14 @@ type ContextMenuPatchCallbackReturn = (() => void) | void;
|
||||
* @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example
|
||||
* @returns A callback which is only ran once used to modify the context menu elements (Use to avoid duplicates)
|
||||
*/
|
||||
export type NavContextMenuPatchCallback = (children: Array<React.ReactElement>, ...args: Array<any>) => ContextMenuPatchCallbackReturn;
|
||||
export type NavContextMenuPatchCallback = (children: Array<ReactElement | null>, ...args: Array<any>) => ContextMenuPatchCallbackReturn;
|
||||
/**
|
||||
* @param navId The navId of the context menu being patched
|
||||
* @param children The rendered context menu elements
|
||||
* @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example
|
||||
* @returns A callback which is only ran once used to modify the context menu elements (Use to avoid duplicates)
|
||||
*/
|
||||
export type GlobalContextMenuPatchCallback = (navId: string, children: Array<React.ReactElement>, ...args: Array<any>) => ContextMenuPatchCallbackReturn;
|
||||
export type GlobalContextMenuPatchCallback = (navId: string, children: Array<ReactElement | null>, ...args: Array<any>) => ContextMenuPatchCallbackReturn;
|
||||
|
||||
const ContextMenuLogger = new Logger("ContextMenu");
|
||||
|
||||
@ -89,15 +89,18 @@ export function removeGlobalContextMenuPatch(patch: GlobalContextMenuPatchCallba
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function for finding the children array of a group nested inside a context menu based on the id of one of its childs
|
||||
* @param id The id of the child
|
||||
* A helper function for finding the children array of a group nested inside a context menu based on the id(s) of its children
|
||||
* @param id The id of the child. If an array is specified, all ids will be tried
|
||||
* @param children The context menu children
|
||||
*/
|
||||
export function findGroupChildrenByChildId(id: string, children: Array<React.ReactElement>, _itemsArray?: Array<React.ReactElement>): Array<React.ReactElement> | null {
|
||||
export function findGroupChildrenByChildId(id: string | string[], children: Array<ReactElement | null>, _itemsArray?: Array<ReactElement | null>): Array<ReactElement | null> | null {
|
||||
for (const child of children) {
|
||||
if (child == null) continue;
|
||||
|
||||
if (child.props?.id === id) return _itemsArray ?? null;
|
||||
if (
|
||||
(Array.isArray(id) && id.some(id => child.props?.id === id))
|
||||
|| child.props?.id === id
|
||||
) return _itemsArray ?? null;
|
||||
|
||||
let nextChildren = child.props?.children;
|
||||
if (nextChildren) {
|
||||
@ -117,7 +120,7 @@ export function findGroupChildrenByChildId(id: string, children: Array<React.Rea
|
||||
interface ContextMenuProps {
|
||||
contextMenuApiArguments?: Array<any>;
|
||||
navId: string;
|
||||
children: Array<ReactElement>;
|
||||
children: Array<ReactElement | null>;
|
||||
"aria-label": string;
|
||||
onSelect: (() => void) | undefined;
|
||||
onClose: (callback: (...args: Array<any>) => any) => void;
|
||||
|
@ -18,24 +18,15 @@
|
||||
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { MessageStore } from "@webpack/common";
|
||||
import { CustomEmoji } from "@webpack/types";
|
||||
import type { Channel, Message } from "discord-types/general";
|
||||
import type { Promisable } from "type-fest";
|
||||
|
||||
const MessageEventsLogger = new Logger("MessageEvents", "#e5c890");
|
||||
|
||||
export interface Emoji {
|
||||
require_colons: boolean,
|
||||
originalName: string,
|
||||
animated: boolean;
|
||||
guildId: string,
|
||||
name: string,
|
||||
url: string,
|
||||
id: string,
|
||||
}
|
||||
|
||||
export interface MessageObject {
|
||||
content: string,
|
||||
validNonShortcutEmojis: Emoji[];
|
||||
validNonShortcutEmojis: CustomEmoji[];
|
||||
invalidEmojis: any[];
|
||||
tts: boolean;
|
||||
}
|
||||
|
@ -266,7 +266,12 @@ export function definePluginSettings<D extends SettingsDefinition, C extends Set
|
||||
def,
|
||||
checks: checks ?? {},
|
||||
pluginName: "",
|
||||
|
||||
withPrivateSettings<T>() {
|
||||
return this as DefinedSettings<D, C> & { store: T; };
|
||||
}
|
||||
};
|
||||
|
||||
return definedSettings;
|
||||
}
|
||||
|
||||
|
12
src/components/ExpandableHeader.css
Normal file
12
src/components/ExpandableHeader.css
Normal file
@ -0,0 +1,12 @@
|
||||
.vc-expandableheader-center-flex {
|
||||
display: flex;
|
||||
justify-items: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.vc-expandableheader-btn {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
108
src/components/ExpandableHeader.tsx
Normal file
108
src/components/ExpandableHeader.tsx
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { classNameFactory } from "@api/Styles";
|
||||
import { Text, Tooltip, useState } from "@webpack/common";
|
||||
export const cl = classNameFactory("vc-expandableheader-");
|
||||
import "./ExpandableHeader.css";
|
||||
|
||||
export interface ExpandableHeaderProps {
|
||||
onMoreClick?: () => void;
|
||||
moreTooltipText?: string;
|
||||
onDropDownClick?: (state: boolean) => void;
|
||||
defaultState?: boolean;
|
||||
headerText: string;
|
||||
children: React.ReactNode;
|
||||
buttons?: React.ReactNode[];
|
||||
}
|
||||
|
||||
export default function ExpandableHeader({ children, onMoreClick, buttons, moreTooltipText, defaultState = false, onDropDownClick, headerText }: ExpandableHeaderProps) {
|
||||
const [showContent, setShowContent] = useState(defaultState);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
marginBottom: "8px"
|
||||
}}>
|
||||
<Text
|
||||
tag="h2"
|
||||
variant="eyebrow"
|
||||
style={{
|
||||
color: "var(--header-primary)",
|
||||
display: "inline"
|
||||
}}
|
||||
>
|
||||
{headerText}
|
||||
</Text>
|
||||
|
||||
<div className={cl("center-flex")}>
|
||||
{
|
||||
buttons ?? null
|
||||
}
|
||||
|
||||
{
|
||||
onMoreClick && // only show more button if callback is provided
|
||||
<Tooltip text={moreTooltipText}>
|
||||
{tooltipProps => (
|
||||
<button
|
||||
{...tooltipProps}
|
||||
className={cl("btn")}
|
||||
onClick={onMoreClick}>
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path fill="var(--text-normal)" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</Tooltip>
|
||||
}
|
||||
|
||||
|
||||
<Tooltip text={showContent ? "Hide " + headerText : "Show " + headerText}>
|
||||
{tooltipProps => (
|
||||
<button
|
||||
{...tooltipProps}
|
||||
className={cl("btn")}
|
||||
onClick={() => {
|
||||
setShowContent(v => !v);
|
||||
onDropDownClick?.(showContent);
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
transform={showContent ? "scale(1 -1)" : "scale(1 1)"}
|
||||
>
|
||||
<path fill="var(--text-normal)" d="M16.59 8.59003L12 13.17L7.41 8.59003L6 10L12 16L18 10L16.59 8.59003Z" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
{showContent && children}
|
||||
</>
|
||||
);
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
|
||||
import { generateId } from "@api/Commands";
|
||||
import { useSettings } from "@api/Settings";
|
||||
import { disableStyle, enableStyle } from "@api/Styles";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Flex } from "@components/Flex";
|
||||
import { proxyLazy } from "@utils/lazy";
|
||||
@ -40,6 +41,7 @@ import {
|
||||
SettingSliderComponent,
|
||||
SettingTextComponent
|
||||
} from "./components";
|
||||
import hideBotTagStyle from "./userPopoutHideBotTag.css?managed";
|
||||
|
||||
const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers"));
|
||||
const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
|
||||
@ -50,11 +52,12 @@ interface PluginModalProps extends ModalProps {
|
||||
onRestartNeeded(): void;
|
||||
}
|
||||
|
||||
/** To stop discord making unwanted requests... */
|
||||
function makeDummyUser(user: { name: string, id: BigInt; }) {
|
||||
function makeDummyUser(user: { username: string; id?: string; avatar?: string; }) {
|
||||
const newUser = new UserRecord({
|
||||
username: user.name,
|
||||
id: generateId(),
|
||||
username: user.username,
|
||||
id: user.id ?? generateId(),
|
||||
avatar: user.avatar,
|
||||
/** To stop discord making unwanted requests... */
|
||||
bot: true,
|
||||
});
|
||||
FluxDispatcher.dispatch({
|
||||
@ -89,14 +92,27 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
||||
const hasSettings = Boolean(pluginSettings && plugin.options);
|
||||
|
||||
React.useEffect(() => {
|
||||
enableStyle(hideBotTagStyle);
|
||||
|
||||
let originalUser: User;
|
||||
(async () => {
|
||||
for (const user of plugin.authors.slice(0, 6)) {
|
||||
const author = user.id
|
||||
? await UserUtils.fetchUser(`${user.id}`).catch(() => makeDummyUser(user))
|
||||
: makeDummyUser(user);
|
||||
? await UserUtils.fetchUser(`${user.id}`)
|
||||
// only show name & pfp and no actions so users cannot harass plugin devs for support (send dms, add as friend, etc)
|
||||
.then(u => (originalUser = u, makeDummyUser(u)))
|
||||
.catch(() => makeDummyUser({ username: user.name }))
|
||||
: makeDummyUser({ username: user.name });
|
||||
|
||||
setAuthors(a => [...a, author]);
|
||||
}
|
||||
})();
|
||||
|
||||
return () => {
|
||||
disableStyle(hideBotTagStyle);
|
||||
if (originalUser)
|
||||
FluxDispatcher.dispatch({ type: "USER_UPDATE", user: originalUser });
|
||||
};
|
||||
}, []);
|
||||
|
||||
async function saveAndClose() {
|
||||
|
3
src/components/PluginSettings/userPopoutHideBotTag.css
Normal file
3
src/components/PluginSettings/userPopoutHideBotTag.css
Normal file
@ -0,0 +1,3 @@
|
||||
[class|="userPopoutOuter"] [class*="botTag"] {
|
||||
display: none;
|
||||
}
|
@ -24,15 +24,13 @@ import { Heart } from "@components/Heart";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { Margins } from "@utils/margins";
|
||||
import { isPluginDev } from "@utils/misc";
|
||||
import { closeModal, Modals, openModal } from "@utils/modal";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Forms, Toasts } from "@webpack/common";
|
||||
|
||||
const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/attachments/1033680203433660458/1092089947126780035/favicon.png";
|
||||
|
||||
/** List of vencord contributor IDs */
|
||||
const contributorIds: string[] = Object.values(Devs).map(d => d.id.toString());
|
||||
|
||||
const ContributorBadge: ProfileBadge = {
|
||||
description: "Vencord Contributor",
|
||||
image: CONTRIBUTOR_BADGE,
|
||||
@ -43,7 +41,7 @@ const ContributorBadge: ProfileBadge = {
|
||||
transform: "scale(0.9)" // The image is a bit too big compared to default badges
|
||||
}
|
||||
},
|
||||
shouldShow: ({ user }) => contributorIds.includes(user.id),
|
||||
shouldShow: ({ user }) => isPluginDev(user.id),
|
||||
link: "https://github.com/Vendicated/Vencord"
|
||||
};
|
||||
|
||||
|
@ -24,12 +24,11 @@ import { Margins } from "@utils/margins";
|
||||
import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByCodeLazy, findStoreLazy } from "@webpack";
|
||||
import { FluxDispatcher, Forms, GuildStore, Menu, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common";
|
||||
import { EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common";
|
||||
import { Promisable } from "type-fest";
|
||||
|
||||
const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n;
|
||||
|
||||
const GuildEmojiStore = findStoreLazy("EmojiStore");
|
||||
const StickersStore = findStoreLazy("StickersStore");
|
||||
const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS(");
|
||||
|
||||
@ -129,7 +128,7 @@ function getGuildCandidates(data: Data) {
|
||||
const { isAnimated } = data as Emoji;
|
||||
|
||||
const emojiSlots = g.getMaxEmojiSlots();
|
||||
const { emojis } = GuildEmojiStore.getGuilds()[g.id];
|
||||
const { emojis } = EmojiStore.getGuilds()[g.id];
|
||||
|
||||
let count = 0;
|
||||
for (const emoji of emojis)
|
||||
@ -194,7 +193,8 @@ function CloneModal({ data }: { data: Sticker | Emoji; }) {
|
||||
setName(v);
|
||||
}}
|
||||
validate={v =>
|
||||
(v.length > 1 && v.length < 32 && nameValidator.test(v))
|
||||
(data.t === "Emoji" && v.length > 2 && v.length < 32 && nameValidator.test(v))
|
||||
|| (data.t === "Sticker" && v.length > 2 && v.length < 30)
|
||||
|| "Name must be between 2 and 32 characters and only contain alphanumeric characters"
|
||||
}
|
||||
/>
|
||||
|
@ -22,11 +22,12 @@ import { Devs } from "@utils/constants";
|
||||
import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies";
|
||||
import { getCurrentGuild } from "@utils/discord";
|
||||
import { proxyLazy } from "@utils/lazy";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
||||
import { ChannelStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common";
|
||||
import { ChannelStore, EmojiStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common";
|
||||
import type { Message } from "discord-types/general";
|
||||
import type { ReactNode } from "react";
|
||||
import type { ReactElement, ReactNode } from "react";
|
||||
|
||||
const DRAFT_TYPE = 0;
|
||||
const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR");
|
||||
@ -38,8 +39,6 @@ const StickerStore = findStoreLazy("StickersStore") as {
|
||||
getAllGuildStickers(): Map<string, Sticker[]>;
|
||||
getStickerById(id: string): Sticker | undefined;
|
||||
};
|
||||
const EmojiStore = findStoreLazy("EmojiStore");
|
||||
|
||||
|
||||
function searchProtoClass(localName: string, parentProtoClass: any) {
|
||||
if (!parentProtoClass) return;
|
||||
@ -57,7 +56,7 @@ const ClientThemeSettingsProto = proxyLazy(() => searchProtoClass("clientThemeSe
|
||||
const USE_EXTERNAL_EMOJIS = 1n << 18n;
|
||||
const USE_EXTERNAL_STICKERS = 1n << 37n;
|
||||
|
||||
enum EmojiIntentions {
|
||||
const enum EmojiIntentions {
|
||||
REACTION = 0,
|
||||
STATUS = 1,
|
||||
COMMUNITY_CONTENT = 2,
|
||||
@ -68,6 +67,14 @@ enum EmojiIntentions {
|
||||
SOUNDBOARD = 7
|
||||
}
|
||||
|
||||
const enum StickerType {
|
||||
PNG = 1,
|
||||
APNG = 2,
|
||||
LOTTIE = 3,
|
||||
// don't think you can even have gif stickers but the docs have it
|
||||
GIF = 4
|
||||
}
|
||||
|
||||
interface BaseSticker {
|
||||
available: boolean;
|
||||
description: string;
|
||||
@ -173,6 +180,10 @@ export default definePlugin({
|
||||
{
|
||||
match: /(&&!\i&&)!(\i)(?=\)return \i\.\i\.DISALLOW_EXTERNAL;)/,
|
||||
replace: (_, rest, canUseExternal) => `${rest}(!${canUseExternal}&&(typeof fakeNitroIntention==="undefined"||![${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention)))`
|
||||
},
|
||||
{
|
||||
match: /if\(!\i\.available/,
|
||||
replace: m => `${m}&&(typeof fakeNitroIntention==="undefined"||![${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention))`
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -321,7 +332,7 @@ export default definePlugin({
|
||||
},
|
||||
|
||||
handleProtoChange(proto: any, user: any) {
|
||||
if ((!proto.appearance && !AppearanceSettingsProto) || !UserSettingsProtoStore) return;
|
||||
if (proto == null || typeof proto === "string" || !UserSettingsProtoStore || (!proto.appearance && !AppearanceSettingsProto)) return;
|
||||
|
||||
const premiumType: number = user?.premium_type ?? UserStore?.getCurrentUser()?.premiumType ?? 0;
|
||||
|
||||
@ -382,70 +393,137 @@ export default definePlugin({
|
||||
});
|
||||
},
|
||||
|
||||
patchFakeNitroEmojisOrRemoveStickersLinks(content: Array<any>, inline: boolean) {
|
||||
if (content.length > 1 && !settings.store.transformCompoundSentence) return content;
|
||||
trimContent(content: Array<any>) {
|
||||
const firstContent = content[0];
|
||||
if (typeof firstContent === "string") content[0] = firstContent.trimStart();
|
||||
if (content[0] === "") content.shift();
|
||||
|
||||
const newContent: Array<any> = [];
|
||||
const lastIndex = content.length - 1;
|
||||
const lastContent = content[lastIndex];
|
||||
if (typeof lastContent === "string") content[lastIndex] = lastContent.trimEnd();
|
||||
if (content[lastIndex] === "") content.pop();
|
||||
},
|
||||
|
||||
clearEmptyArrayItems(array: Array<any>) {
|
||||
return array.filter(item => item != null);
|
||||
},
|
||||
|
||||
ensureChildrenIsArray(child: ReactElement) {
|
||||
if (!Array.isArray(child.props.children)) child.props.children = [child.props.children];
|
||||
},
|
||||
|
||||
patchFakeNitroEmojisOrRemoveStickersLinks(content: Array<any>, inline: boolean) {
|
||||
// If content has more than one child or it's a single ReactElement like a header or list
|
||||
if ((content.length > 1 || typeof content[0]?.type === "string") && !settings.store.transformCompoundSentence) return content;
|
||||
|
||||
let nextIndex = content.length;
|
||||
|
||||
for (const element of content) {
|
||||
if (element.props?.trusted == null) {
|
||||
newContent.push(element);
|
||||
continue;
|
||||
}
|
||||
|
||||
const transformLinkChild = (child: ReactElement) => {
|
||||
if (settings.store.transformEmojis) {
|
||||
const fakeNitroMatch = element.props.href.match(fakeNitroEmojiRegex);
|
||||
const fakeNitroMatch = child.props.href.match(fakeNitroEmojiRegex);
|
||||
if (fakeNitroMatch) {
|
||||
let url: URL | null = null;
|
||||
try {
|
||||
url = new URL(element.props.href);
|
||||
url = new URL(child.props.href);
|
||||
} catch { }
|
||||
|
||||
const emojiName = EmojiStore.getCustomEmojiById(fakeNitroMatch[1])?.name ?? url?.searchParams.get("name") ?? "FakeNitroEmoji";
|
||||
|
||||
newContent.push(Parser.defaultRules.customEmoji.react({
|
||||
jumboable: !inline && content.length === 1,
|
||||
return Parser.defaultRules.customEmoji.react({
|
||||
jumboable: !inline && content.length === 1 && typeof content[0].type !== "string",
|
||||
animated: fakeNitroMatch[2] === "gif",
|
||||
emojiId: fakeNitroMatch[1],
|
||||
name: emojiName,
|
||||
fake: true
|
||||
}, void 0, { key: String(nextIndex++) }));
|
||||
|
||||
continue;
|
||||
}, void 0, { key: String(nextIndex++) });
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.store.transformStickers) {
|
||||
if (fakeNitroStickerRegex.test(element.props.href)) continue;
|
||||
if (fakeNitroStickerRegex.test(child.props.href)) return null;
|
||||
|
||||
const gifMatch = element.props.href.match(fakeNitroGifStickerRegex);
|
||||
const gifMatch = child.props.href.match(fakeNitroGifStickerRegex);
|
||||
if (gifMatch) {
|
||||
// There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickerStore contains the id of the fake sticker
|
||||
if (StickerStore.getStickerById(gifMatch[1])) continue;
|
||||
if (StickerStore.getStickerById(gifMatch[1])) return null;
|
||||
}
|
||||
}
|
||||
|
||||
newContent.push(element);
|
||||
return child;
|
||||
};
|
||||
|
||||
const transformChild = (child: ReactElement) => {
|
||||
if (child?.props?.trusted != null) return transformLinkChild(child);
|
||||
if (child?.props?.children != null) {
|
||||
if (!Array.isArray(child.props.children)) {
|
||||
child.props.children = modifyChild(child.props.children);
|
||||
return child;
|
||||
}
|
||||
|
||||
child.props.children = modifyChildren(child.props.children);
|
||||
if (child.props.children.length === 0) return null;
|
||||
return child;
|
||||
}
|
||||
|
||||
return child;
|
||||
};
|
||||
|
||||
const modifyChild = (child: ReactElement) => {
|
||||
const newChild = transformChild(child);
|
||||
|
||||
if (newChild?.type === "ul" || newChild?.type === "ol") {
|
||||
this.ensureChildrenIsArray(newChild);
|
||||
if (newChild.props.children.length === 0) return null;
|
||||
|
||||
let listHasAnItem = false;
|
||||
for (const [index, child] of newChild.props.children.entries()) {
|
||||
if (child == null) {
|
||||
delete newChild.props.children[index];
|
||||
continue;
|
||||
}
|
||||
|
||||
this.ensureChildrenIsArray(child);
|
||||
if (child.props.children.length > 0) listHasAnItem = true;
|
||||
else delete newChild.props.children[index];
|
||||
}
|
||||
|
||||
if (!listHasAnItem) return null;
|
||||
|
||||
newChild.props.children = this.clearEmptyArrayItems(newChild.props.children);
|
||||
}
|
||||
|
||||
return newChild;
|
||||
};
|
||||
|
||||
const modifyChildren = (children: Array<ReactElement>) => {
|
||||
for (const [index, child] of children.entries()) children[index] = modifyChild(child);
|
||||
|
||||
children = this.clearEmptyArrayItems(children);
|
||||
this.trimContent(children);
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
try {
|
||||
return modifyChildren(window._.cloneDeep(content));
|
||||
} catch (err) {
|
||||
new Logger("FakeNitro").error(err);
|
||||
return content;
|
||||
}
|
||||
|
||||
const firstContent = newContent[0];
|
||||
if (typeof firstContent === "string") newContent[0] = firstContent.trimStart();
|
||||
|
||||
return newContent;
|
||||
},
|
||||
|
||||
patchFakeNitroStickers(stickers: Array<any>, message: Message) {
|
||||
const itemsToMaybePush: Array<string> = [];
|
||||
|
||||
const contentItems = message.content.split(/\s/);
|
||||
if (contentItems.length === 1 && !settings.store.transformCompoundSentence) itemsToMaybePush.push(contentItems[0]);
|
||||
else itemsToMaybePush.push(...contentItems);
|
||||
if (settings.store.transformCompoundSentence) itemsToMaybePush.push(...contentItems);
|
||||
else if (contentItems.length === 1) itemsToMaybePush.push(contentItems[0]);
|
||||
|
||||
itemsToMaybePush.push(...message.attachments.filter(attachment => attachment.content_type === "image/gif").map(attachment => attachment.url));
|
||||
|
||||
for (const item of itemsToMaybePush) {
|
||||
if (!settings.store.transformCompoundSentence && !item.startsWith("http")) continue;
|
||||
|
||||
const imgMatch = item.match(fakeNitroStickerRegex);
|
||||
if (imgMatch) {
|
||||
let url: URL | null = null;
|
||||
@ -482,10 +560,13 @@ export default definePlugin({
|
||||
},
|
||||
|
||||
shouldIgnoreEmbed(embed: Message["embeds"][number], message: Message) {
|
||||
if (message.content.split(/\s/).length > 1 && !settings.store.transformCompoundSentence) return false;
|
||||
const contentItems = message.content.split(/\s/);
|
||||
if (contentItems.length > 1 && !settings.store.transformCompoundSentence) return false;
|
||||
|
||||
switch (embed.type) {
|
||||
case "image": {
|
||||
if (!settings.store.transformCompoundSentence && !contentItems.includes(embed.url!) && !contentItems.includes(embed.image!.proxyURL)) return false;
|
||||
|
||||
if (settings.store.transformEmojis) {
|
||||
if (fakeNitroEmojiRegex.test(embed.url!)) return true;
|
||||
}
|
||||
@ -544,7 +625,7 @@ export default definePlugin({
|
||||
}
|
||||
},
|
||||
|
||||
hasPermissionToUseExternalEmojis(channelId: string) {
|
||||
hasPermissionToUseExternalEmojis(channelId: string): boolean {
|
||||
const channel = ChannelStore.getChannel(channelId);
|
||||
|
||||
if (!channel || channel.isDM() || channel.isGroupDM() || channel.isMultiUserDM()) return true;
|
||||
@ -625,8 +706,9 @@ export default definePlugin({
|
||||
},
|
||||
|
||||
start() {
|
||||
const settings = Settings.plugins.FakeNitro;
|
||||
if (!settings.enableEmojiBypass && !settings.enableStickerBypass) {
|
||||
const s = settings.store;
|
||||
|
||||
if (!s.enableEmojiBypass && !s.enableStickerBypass) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -638,39 +720,37 @@ export default definePlugin({
|
||||
const { guildId } = this;
|
||||
|
||||
stickerBypass: {
|
||||
if (!settings.enableStickerBypass)
|
||||
if (!s.enableStickerBypass)
|
||||
break stickerBypass;
|
||||
|
||||
const sticker = StickerStore.getStickerById(extra.stickers?.[0]!);
|
||||
if (!sticker)
|
||||
break stickerBypass;
|
||||
|
||||
if (sticker.available !== false && ((this.canUseStickers && this.hasPermissionToUseExternalStickers(channelId)) || (sticker as GuildSticker)?.guild_id === guildId))
|
||||
// Discord Stickers are now free yayyy!! :D
|
||||
if ("pack_id" in sticker)
|
||||
break stickerBypass;
|
||||
|
||||
let link = this.getStickerLink(sticker.id);
|
||||
if (sticker.format_type === 2) {
|
||||
const canUseStickers = this.canUseStickers && this.hasPermissionToUseExternalStickers(channelId);
|
||||
if (sticker.available !== false && (canUseStickers || sticker.guild_id === guildId))
|
||||
break stickerBypass;
|
||||
|
||||
const link = this.getStickerLink(sticker.id);
|
||||
if (sticker.format_type === StickerType.APNG) {
|
||||
this.sendAnimatedSticker(link, sticker.id, channelId);
|
||||
return { cancel: true };
|
||||
} else {
|
||||
if ("pack_id" in sticker) {
|
||||
const packId = sticker.pack_id === "847199849233514549"
|
||||
// Discord moved these stickers into a different pack at some point, but
|
||||
// Distok still uses the old id
|
||||
? "749043879713701898"
|
||||
: sticker.pack_id;
|
||||
|
||||
link = `https://distok.top/stickers/${packId}/${sticker.id}.gif`;
|
||||
}
|
||||
|
||||
extra.stickers!.length = 0;
|
||||
messageObj.content += " " + link + `&name=${encodeURIComponent(sticker.name)}`;
|
||||
messageObj.content += ` ${link}&name=${encodeURIComponent(sticker.name)}`;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!this.canUseEmotes || !this.hasPermissionToUseExternalEmojis(channelId)) && settings.enableEmojiBypass) {
|
||||
if (s.enableEmojiBypass) {
|
||||
const canUseEmotes = this.canUseEmotes && this.hasPermissionToUseExternalEmojis(channelId);
|
||||
|
||||
for (const emoji of messageObj.validNonShortcutEmojis) {
|
||||
if (!emoji.require_colons) continue;
|
||||
if (emoji.available !== false && canUseEmotes) continue;
|
||||
if (emoji.guildId === guildId && !emoji.animated) continue;
|
||||
|
||||
const emojiString = `<${emoji.animated ? "a" : ""}:${emoji.originalName || emoji.name}:${emoji.id}>`;
|
||||
@ -688,23 +768,25 @@ export default definePlugin({
|
||||
});
|
||||
|
||||
this.preEdit = addPreEditListener((channelId, __, messageObj) => {
|
||||
if (this.canUseEmotes && this.hasPermissionToUseExternalEmojis(channelId)) return;
|
||||
if (!s.enableEmojiBypass) return;
|
||||
|
||||
const canUseEmotes = this.canUseEmotes && this.hasPermissionToUseExternalEmojis(channelId);
|
||||
|
||||
const { guildId } = this;
|
||||
|
||||
for (const [emojiStr, _, emojiId] of messageObj.content.matchAll(/(?<!\\)<a?:(\w+):(\d+)>/ig)) {
|
||||
messageObj.content = messageObj.content.replace(/(?<!\\)<a?:(?:\w+):(\d+)>/ig, (emojiStr, emojiId, offset, origStr) => {
|
||||
const emoji = EmojiStore.getCustomEmojiById(emojiId);
|
||||
if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue;
|
||||
if (!emoji.require_colons) continue;
|
||||
if (emoji == null) return emojiStr;
|
||||
if (!emoji.require_colons) return emojiStr;
|
||||
if (emoji.available !== false && canUseEmotes) return emojiStr;
|
||||
if (emoji.guildId === guildId && !emoji.animated) return emojiStr;
|
||||
|
||||
const url = emoji.url.replace(/\?size=\d+/, "?" + new URLSearchParams({
|
||||
size: Settings.plugins.FakeNitro.emojiSize,
|
||||
name: encodeURIComponent(emoji.name)
|
||||
}));
|
||||
messageObj.content = messageObj.content.replace(emojiStr, (match, offset, origStr) => {
|
||||
return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`;
|
||||
});
|
||||
}
|
||||
return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + emojiStr.length)}`;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
83
src/plugins/favEmojiFirst.ts
Normal file
83
src/plugins/favEmojiFirst.ts
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { EmojiStore } from "@webpack/common";
|
||||
import { Emoji } from "@webpack/types";
|
||||
|
||||
interface EmojiAutocompleteState {
|
||||
query?: {
|
||||
type: string;
|
||||
typeInfo: {
|
||||
sentinel: string;
|
||||
};
|
||||
results: {
|
||||
emojis: Emoji[] & { sliceTo?: number; };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "FavoriteEmojiFirst",
|
||||
authors: [Devs.Aria, Devs.Ven],
|
||||
description: "Puts your favorite emoji first in the emoji autocomplete.",
|
||||
patches: [
|
||||
{
|
||||
find: ".activeCommandOption",
|
||||
replacement: [
|
||||
{
|
||||
// = someFunc(a.selectedIndex); ...trackEmojiSearch({ state: theState, isInPopoutExperimental: someBool })
|
||||
match: /=\i\(\i\.selectedIndex\);(?=.+?state:(\i),isInPopoutExperiment:\i)/,
|
||||
// self.sortEmojis(theState)
|
||||
replace: "$&$self.sortEmojis($1);"
|
||||
},
|
||||
|
||||
// set maxCount to Infinity so our sortEmojis callback gets the entire list, not just the first 10
|
||||
// and remove Discord's emojiResult slice, storing the endIndex on the array for us to use later
|
||||
{
|
||||
// searchEmojis(...,maxCount: stuff) ... endEmojis = emojis.slice(0, maxCount - gifResults.length)
|
||||
match: /,maxCount:(\i)(.+?)=(\i)\.slice\(0,(\1-\i\.length)\)/,
|
||||
// ,maxCount:Infinity ... endEmojis = (emojis.sliceTo = n, emojis)
|
||||
replace: ",maxCount:Infinity$2=($3.sliceTo=$4,$3)"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
sortEmojis({ query }: EmojiAutocompleteState) {
|
||||
if (
|
||||
query?.type !== "EMOJIS_AND_STICKERS"
|
||||
|| query.typeInfo?.sentinel !== ":"
|
||||
|| !query.results?.emojis?.length
|
||||
) return;
|
||||
|
||||
const emojiContext = EmojiStore.getDisambiguatedEmojiContext();
|
||||
|
||||
query.results.emojis = query.results.emojis.sort((a, b) => {
|
||||
const aIsFavorite = emojiContext.isFavoriteEmojiWithoutFetchingLatest(a);
|
||||
const bIsFavorite = emojiContext.isFavoriteEmojiWithoutFetchingLatest(b);
|
||||
|
||||
if (aIsFavorite && !bIsFavorite) return -1;
|
||||
|
||||
if (!aIsFavorite && bIsFavorite) return 1;
|
||||
|
||||
return 0;
|
||||
}).slice(0, query.results.emojis.sliceTo ?? 10);
|
||||
}
|
||||
});
|
@ -20,7 +20,7 @@ import { get, set } from "@api/DataStore";
|
||||
import { addButton, removeButton } from "@api/MessagePopover";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { ChannelStore, FluxDispatcher } from "@webpack/common";
|
||||
import { ChannelStore } from "@webpack/common";
|
||||
|
||||
let style: HTMLStyleElement;
|
||||
|
||||
@ -101,11 +101,5 @@ export default definePlugin({
|
||||
|
||||
await saveHiddenMessages(ids);
|
||||
await this.buildCss();
|
||||
|
||||
// update is necessary to rerender the PopOver
|
||||
FluxDispatcher.dispatch({
|
||||
type: "MESSAGE_UPDATE",
|
||||
message: { id }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getStegCloak } from "@utils/dependencies";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Button, ButtonLooks, ButtonWrapperClasses, ChannelStore, FluxDispatcher, Tooltip } from "@webpack/common";
|
||||
import { Button, ButtonLooks, ButtonWrapperClasses, ChannelStore, FluxDispatcher, RestAPI, Tooltip } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
|
||||
import { buildDecModal } from "./components/DecryptionModal";
|
||||
@ -123,7 +123,7 @@ const settings = definePluginSettings({
|
||||
|
||||
export default definePlugin({
|
||||
name: "InvisibleChat",
|
||||
description: "Encrypt your Messages in a non-suspicious way! This plugin makes requests to >>https://embed.sammcheese.net<< to provide embeds to decrypted links!",
|
||||
description: "Encrypt your Messages in a non-suspicious way!",
|
||||
authors: [Devs.SammCheese],
|
||||
dependencies: ["MessagePopoverAPI"],
|
||||
patches: [
|
||||
@ -178,25 +178,13 @@ export default definePlugin({
|
||||
|
||||
// Gets the Embed of a Link
|
||||
async getEmbed(url: URL): Promise<Object | {}> {
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
||||
|
||||
const options: RequestInit = {
|
||||
signal: controller.signal,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
url,
|
||||
}),
|
||||
};
|
||||
|
||||
// AWS hosted url to discord embed object
|
||||
const rawRes = await fetch(this.EMBED_API_URL, options);
|
||||
clearTimeout(timeout);
|
||||
|
||||
return await rawRes.json();
|
||||
const { body } = await RestAPI.post({
|
||||
url: "/unfurler/embed-urls",
|
||||
body: {
|
||||
urls: [url]
|
||||
}
|
||||
});
|
||||
return await body.embeds[0];
|
||||
},
|
||||
|
||||
async buildEmbed(message: any, revealed: string): Promise<void> {
|
||||
|
@ -72,7 +72,7 @@ enum ActivityFlag {
|
||||
INSTANCE = 1 << 0,
|
||||
}
|
||||
|
||||
const applicationId = "1043533871037284423";
|
||||
const applicationId = "1108588077900898414";
|
||||
const placeholderId = "2a96cbd8b46e442fc41c2b86b821562f";
|
||||
|
||||
const logger = new Logger("LastFMRichPresence");
|
||||
@ -167,6 +167,7 @@ export default definePlugin({
|
||||
settings,
|
||||
|
||||
start() {
|
||||
this.updatePresence();
|
||||
this.updateInterval = setInterval(() => { this.updatePresence(); }, 16000);
|
||||
},
|
||||
|
||||
@ -198,7 +199,7 @@ export default definePlugin({
|
||||
|
||||
const trackData = json.recenttracks?.track[0];
|
||||
|
||||
if (!trackData || !trackData["@attr"]?.nowplaying)
|
||||
if (!trackData?.["@attr"]?.nowplaying)
|
||||
return null;
|
||||
|
||||
// why does the json api have xml structure
|
||||
|
@ -225,6 +225,8 @@ function MessageEmbedAccessory({ message }: { message: Message; }) {
|
||||
} else {
|
||||
const msg = { ...message } as any;
|
||||
delete msg.embeds;
|
||||
delete msg.interaction;
|
||||
|
||||
messageFetchQueue.push(() => fetchMessage(channelID, messageID)
|
||||
.then(m => m && FluxDispatcher.dispatch({
|
||||
type: "MESSAGE_UPDATE",
|
||||
|
105
src/plugins/partyMode.ts
Normal file
105
src/plugins/partyMode.ts
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findStoreLazy } from "@webpack";
|
||||
import { GenericStore } from "@webpack/common";
|
||||
|
||||
const PoggerModeSettingsStore: GenericStore = findStoreLazy("PoggermodeSettingsStore");
|
||||
|
||||
const enum Intensity {
|
||||
Normal,
|
||||
Better,
|
||||
ProjectX,
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
superIntensePartyMode: {
|
||||
description: "Party intensity",
|
||||
type: OptionType.SELECT,
|
||||
options: [
|
||||
{ label: "Normal", value: Intensity.Normal, default: true },
|
||||
{ label: "Better", value: Intensity.Better },
|
||||
{ label: "Project X", value: Intensity.ProjectX },
|
||||
],
|
||||
restartNeeded: false,
|
||||
onChange: setSettings
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "Party mode 🎉",
|
||||
description: "Allows you to use party mode cause the party never ends ✨",
|
||||
authors: [Devs.UwUDev],
|
||||
settings,
|
||||
|
||||
start() {
|
||||
setPoggerState(true);
|
||||
setSettings(settings.store.superIntensePartyMode);
|
||||
},
|
||||
|
||||
stop() {
|
||||
setPoggerState(false);
|
||||
},
|
||||
});
|
||||
|
||||
function setPoggerState(state: boolean) {
|
||||
Object.assign(PoggerModeSettingsStore.__getLocalVars().state, {
|
||||
enabled: state,
|
||||
settingsVisible: state
|
||||
});
|
||||
}
|
||||
|
||||
function setSettings(intensity: Intensity) {
|
||||
const state = {
|
||||
screenshakeEnabledLocations: { 0: true, 1: true, 2: true },
|
||||
shakeIntensity: 1,
|
||||
confettiSize: 16,
|
||||
confettiCount: 5,
|
||||
combosRequiredCount: 1
|
||||
};
|
||||
|
||||
switch (intensity) {
|
||||
case Intensity.Normal: {
|
||||
Object.assign(state, {
|
||||
screenshakeEnabledLocations: { 0: true, 1: false, 2: false },
|
||||
combosRequiredCount: 5
|
||||
});
|
||||
break;
|
||||
}
|
||||
case Intensity.Better: {
|
||||
Object.assign(state, {
|
||||
confettiSize: 12,
|
||||
confettiCount: 8,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case Intensity.ProjectX: {
|
||||
Object.assign(state, {
|
||||
shakeIntensity: 20,
|
||||
confettiSize: 25,
|
||||
confettiCount: 15,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(PoggerModeSettingsStore.__getLocalVars().state, state);
|
||||
}
|
@ -17,13 +17,14 @@
|
||||
*/
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import ExpandableHeader from "@components/ExpandableHeader";
|
||||
import { proxyLazy } from "@utils/lazy";
|
||||
import { classes } from "@utils/misc";
|
||||
import { filters, findBulk } from "@webpack";
|
||||
import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore, useState } from "@webpack/common";
|
||||
import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore } from "@webpack/common";
|
||||
import type { Guild, GuildMember } from "discord-types/general";
|
||||
|
||||
import { settings } from "..";
|
||||
import { PermissionsSortOrder, settings } from "..";
|
||||
import { cl, getPermissionString, getSortedRoles, sortUserRoles } from "../utils";
|
||||
import openRolesAndUsersPermissionsModal, { PermissionType, type RoleOrUserPermission } from "./RolesAndUsersPermissions";
|
||||
|
||||
@ -46,7 +47,7 @@ const Classes = proxyLazy(() => {
|
||||
}) as Record<"roles" | "rolePill" | "rolePillBorder" | "desaturateUserColors" | "flex" | "alignCenter" | "justifyCenter" | "svg" | "background" | "dot" | "dotBorderColor" | "roleCircle" | "dotBorderBase" | "flex" | "alignCenter" | "justifyCenter" | "wrap" | "root" | "role" | "roleRemoveButton" | "roleDot" | "roleFlowerStar" | "roleRemoveIcon" | "roleRemoveIconFocused" | "roleVerifiedIcon" | "roleName" | "roleNameOverflow" | "actionButton" | "overflowButton" | "addButton" | "addButtonIcon" | "overflowRolesPopout" | "overflowRolesPopoutArrowWrapper" | "overflowRolesPopoutArrow" | "popoutBottom" | "popoutTop" | "overflowRolesPopoutHeader" | "overflowRolesPopoutHeaderIcon" | "overflowRolesPopoutHeaderText" | "roleIcon", string>;
|
||||
|
||||
function UserPermissionsComponent({ guild, guildMember }: { guild: Guild; guildMember: GuildMember; }) {
|
||||
const [viewPermissions, setViewPermissions] = useState(settings.store.defaultPermissionsDropdownState);
|
||||
const stns = settings.use(["permissionsSortOrder"]);
|
||||
|
||||
const [rolePermissions, userPermissions] = useMemo(() => {
|
||||
const userPermissions: UserPermissions = [];
|
||||
@ -91,62 +92,45 @@ function UserPermissionsComponent({ guild, guildMember }: { guild: Guild; guildM
|
||||
userPermissions.sort((a, b) => b.rolePosition - a.rolePosition);
|
||||
|
||||
return [rolePermissions, userPermissions];
|
||||
}, []);
|
||||
}, [stns.permissionsSortOrder]);
|
||||
|
||||
const { root, role, roleRemoveButton, roleNameOverflow, roles, rolePill, rolePillBorder, roleCircle, roleName } = Classes;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={cl("userperms-title-container")}>
|
||||
<Text className={cl("userperms-title")} variant="eyebrow">Permissions</Text>
|
||||
|
||||
<div>
|
||||
<Tooltip text="Role Details">
|
||||
{tooltipProps => (
|
||||
<button
|
||||
{...tooltipProps}
|
||||
className={cl("userperms-permdetails-btn")}
|
||||
onClick={() =>
|
||||
openRolesAndUsersPermissionsModal(
|
||||
rolePermissions,
|
||||
guild,
|
||||
guildMember.nick || UserStore.getUser(guildMember.userId).username
|
||||
)
|
||||
}
|
||||
<ExpandableHeader
|
||||
headerText="Permissions"
|
||||
moreTooltipText="Role Details"
|
||||
onMoreClick={() =>
|
||||
openRolesAndUsersPermissionsModal(
|
||||
rolePermissions,
|
||||
guild,
|
||||
guildMember.nick || UserStore.getUser(guildMember.userId).username
|
||||
)
|
||||
}
|
||||
defaultState={settings.store.defaultPermissionsDropdownState}
|
||||
buttons={[
|
||||
(<Tooltip text={`Sorting by ${stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? "Highest Role" : "Lowest Role"}`}>
|
||||
{tooltipProps => (
|
||||
<button
|
||||
{...tooltipProps}
|
||||
className={cl("userperms-sortorder-btn")}
|
||||
onClick={() => {
|
||||
stns.permissionsSortOrder = stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? PermissionsSortOrder.LowestRole : PermissionsSortOrder.HighestRole;
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 96 960 960"
|
||||
transform={stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? "scale(1 1)" : "scale(1 -1)"}
|
||||
>
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path fill="var(--text-normal)" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip text={viewPermissions ? "Hide Permissions" : "View Permissions"}>
|
||||
{tooltipProps => (
|
||||
<button
|
||||
{...tooltipProps}
|
||||
className={cl("userperms-toggleperms-btn")}
|
||||
onClick={() => setViewPermissions(v => !v)}
|
||||
>
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
transform={viewPermissions ? "scale(1 -1)" : "scale(1 1)"}
|
||||
>
|
||||
<path fill="var(--text-normal)" d="M16.59 8.59003L12 13.17L7.41 8.59003L6 10L12 16L18 10L16.59 8.59003Z" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{viewPermissions && userPermissions.length > 0 && (
|
||||
<path fill="var(--text-normal)" d="M440 896V409L216 633l-56-57 320-320 320 320-56 57-224-224v487h-80Z" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</Tooltip>)
|
||||
]}>
|
||||
{userPermissions.length > 0 && (
|
||||
<div className={classes(root, roles)}>
|
||||
{userPermissions.map(({ permission, roleColor }) => (
|
||||
<div className={classes(role, rolePill, rolePillBorder)}>
|
||||
@ -168,7 +152,7 @@ function UserPermissionsComponent({ guild, guildMember }: { guild: Guild; guildM
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ExpandableHeader>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import type { Guild, GuildMember } from "discord-types/general";
|
||||
|
||||
import openRolesAndUsersPermissionsModal, { PermissionType, RoleOrUserPermission } from "./components/RolesAndUsersPermissions";
|
||||
import UserPermissions from "./components/UserPermissions";
|
||||
import { getSortedRoles } from "./utils";
|
||||
import { getSortedRoles, sortPermissionOverwrites } from "./utils";
|
||||
|
||||
export const enum PermissionsSortOrder {
|
||||
HighestRole,
|
||||
@ -57,6 +57,8 @@ export const settings = definePluginSettings({
|
||||
});
|
||||
|
||||
function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||
if (type === MenuItemParentType.User && !GuildMemberStore.isMember(guildId, id!)) return null;
|
||||
|
||||
return (
|
||||
<Menu.MenuItem
|
||||
id="perm-viewer-permissions"
|
||||
@ -92,12 +94,12 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||
case MenuItemParentType.Channel: {
|
||||
const channel = ChannelStore.getChannel(id!);
|
||||
|
||||
permissions = Object.values(channel.permissionOverwrites).map(({ id, allow, deny, type }) => ({
|
||||
permissions = sortPermissionOverwrites(Object.values(channel.permissionOverwrites).map(({ id, allow, deny, type }) => ({
|
||||
type: type as PermissionType,
|
||||
id,
|
||||
overwriteAllow: allow,
|
||||
overwriteDeny: deny
|
||||
}));
|
||||
})), guildId);
|
||||
|
||||
header = channel.name;
|
||||
|
||||
@ -122,25 +124,32 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||
);
|
||||
}
|
||||
|
||||
function makeContextMenuPatch(childId: string, type?: MenuItemParentType): NavContextMenuPatchCallback {
|
||||
function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback {
|
||||
return (children, props) => () => {
|
||||
if (!props) return children;
|
||||
|
||||
const group = findGroupChildrenByChildId(childId, children);
|
||||
|
||||
if (group) {
|
||||
const item = (() => {
|
||||
switch (type) {
|
||||
case MenuItemParentType.User:
|
||||
group.push(MenuItem(props.guildId, props.user.id, type));
|
||||
break;
|
||||
return MenuItem(props.guildId, props.user.id, type);
|
||||
case MenuItemParentType.Channel:
|
||||
group.push(MenuItem(props.guild.id, props.channel.id, type));
|
||||
break;
|
||||
return MenuItem(props.guild.id, props.channel.id, type);
|
||||
case MenuItemParentType.Guild:
|
||||
group.push(MenuItem(props.guild.id));
|
||||
break;
|
||||
return MenuItem(props.guild.id);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
if (item == null) return;
|
||||
|
||||
if (group)
|
||||
group.push(item);
|
||||
else if (childId === "roles" && props.guildId)
|
||||
// "roles" may not be present due to the member not having any roles. In that case, add it above "Copy ID"
|
||||
children.splice(-1, 0, <Menu.MenuGroup>{item}</Menu.MenuGroup>);
|
||||
};
|
||||
}
|
||||
|
||||
@ -160,10 +169,10 @@ export default definePlugin({
|
||||
}
|
||||
],
|
||||
|
||||
UserPermissions: (guild: Guild, guildMember: GuildMember) => <UserPermissions guild={guild} guildMember={guildMember} />,
|
||||
UserPermissions: (guild: Guild, guildMember?: GuildMember) => !!guildMember && <UserPermissions guild={guild} guildMember={guildMember} />,
|
||||
|
||||
userContextMenuPatch: makeContextMenuPatch("roles", MenuItemParentType.User),
|
||||
channelContextMenuPatch: makeContextMenuPatch("mute-channel", MenuItemParentType.Channel),
|
||||
channelContextMenuPatch: makeContextMenuPatch(["mute-channel", "unmute-channel"], MenuItemParentType.Channel),
|
||||
guildContextMenuPatch: makeContextMenuPatch("privacy", MenuItemParentType.Guild),
|
||||
|
||||
start() {
|
||||
|
@ -3,21 +3,38 @@
|
||||
.vc-permviewer-userperms-title-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.vc-permviewer-userperms-title {
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.vc-permviewer-userperms-btns-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.vc-permviewer-userperms-sortorder-btn {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.vc-permviewer-userperms-permdetails-btn {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.vc-permviewer-userperms-toggleperms-btn {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* RolesAndUsersPermissions Component */
|
||||
@ -59,7 +76,7 @@
|
||||
align-items: center;
|
||||
padding: 8px 5px;
|
||||
cursor: pointer;
|
||||
width: 165px;
|
||||
width: 230px;
|
||||
}
|
||||
|
||||
.vc-permviewer-perms-list-item > div {
|
||||
@ -110,8 +127,8 @@
|
||||
|
||||
.vc-permviewer-perms-perms-item-icon {
|
||||
border: 1px solid var(--background-modifier-selected);
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
@ -121,6 +138,7 @@
|
||||
position: absolute;
|
||||
right: 0;
|
||||
scale: 0.9;
|
||||
transition: color ease-in 0.1s;
|
||||
}
|
||||
|
||||
.vc-permviewer-perms-perms-item .vc-info-icon:hover {
|
||||
|
@ -18,11 +18,12 @@
|
||||
|
||||
import { classNameFactory } from "@api/Styles";
|
||||
import { wordsToTitle } from "@utils/text";
|
||||
import { i18n, Parser } from "@webpack/common";
|
||||
import { GuildStore, i18n, Parser } from "@webpack/common";
|
||||
import { Guild, GuildMember, Role } from "discord-types/general";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { PermissionsSortOrder, settings } from ".";
|
||||
import { PermissionType } from "./components/RolesAndUsersPermissions";
|
||||
|
||||
export const cl = classNameFactory("vc-permviewer-");
|
||||
|
||||
@ -82,3 +83,16 @@ export function sortUserRoles(roles: Role[]) {
|
||||
return roles;
|
||||
}
|
||||
}
|
||||
|
||||
export function sortPermissionOverwrites<T extends { id: string; type: number; }>(overwrites: T[], guildId: string) {
|
||||
const guild = GuildStore.getGuild(guildId);
|
||||
|
||||
return overwrites.sort((a, b) => {
|
||||
if (a.type !== PermissionType.Role || b.type !== PermissionType.Role) return 0;
|
||||
|
||||
const roleA = guild.roles[a.id];
|
||||
const roleB = guild.roles[b.id];
|
||||
|
||||
return roleB.position - roleA.position;
|
||||
});
|
||||
}
|
||||
|
@ -29,15 +29,15 @@ import { User } from "discord-types/general";
|
||||
|
||||
const SessionsStore = findStoreLazy("SessionsStore");
|
||||
|
||||
function Icon(path: string, viewBox = "0 0 24 24") {
|
||||
function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) {
|
||||
return ({ color, tooltip }: { color: string; tooltip: string; }) => (
|
||||
<Tooltip text={tooltip} >
|
||||
{(tooltipProps: any) => (
|
||||
<svg
|
||||
{...tooltipProps}
|
||||
height="20"
|
||||
width="20"
|
||||
viewBox={viewBox}
|
||||
height={opts?.height ?? 20}
|
||||
width={opts?.width ?? 20}
|
||||
viewBox={opts?.viewBox ?? "0 0 24 24"}
|
||||
fill={color}
|
||||
>
|
||||
<path d={path} />
|
||||
@ -50,8 +50,8 @@ function Icon(path: string, viewBox = "0 0 24 24") {
|
||||
const Icons = {
|
||||
desktop: Icon("M4 2.5c-1.103 0-2 .897-2 2v11c0 1.104.897 2 2 2h7v2H7v2h10v-2h-4v-2h7c1.103 0 2-.896 2-2v-11c0-1.103-.897-2-2-2H4Zm16 2v9H4v-9h16Z"),
|
||||
web: Icon("M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93Zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39Z"),
|
||||
mobile: Icon("M15.5 1h-8A2.5 2.5 0 0 0 5 3.5v17A2.5 2.5 0 0 0 7.5 23h8a2.5 2.5 0 0 0 2.5-2.5v-17A2.5 2.5 0 0 0 15.5 1zm-4 21c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4.5-4H7V4h9v14z"),
|
||||
console: Icon("M14.8 2.7 9 3.1V47h3.3c1.7 0 6.2.3 10 .7l6.7.6V2l-4.2.2c-2.4.1-6.9.3-10 .5zm1.8 6.4c1 1.7-1.3 3.6-2.7 2.2C12.7 10.1 13.5 8 15 8c.5 0 1.2.5 1.6 1.1zM16 33c0 6-.4 10-1 10s-1-4-1-10 .4-10 1-10 1 4 1 10zm15-8v23.3l3.8-.7c2-.3 4.7-.6 6-.6H43V3h-2.2c-1.3 0-4-.3-6-.6L31 1.7V25z", "0 0 50 50"),
|
||||
mobile: Icon("M 187 0 L 813 0 C 916.277 0 1000 83.723 1000 187 L 1000 1313 C 1000 1416.277 916.277 1500 813 1500 L 187 1500 C 83.723 1500 0 1416.277 0 1313 L 0 187 C 0 83.723 83.723 0 187 0 Z M 125 1000 L 875 1000 L 875 250 L 125 250 Z M 500 1125 C 430.964 1125 375 1180.964 375 1250 C 375 1319.036 430.964 1375 500 1375 C 569.036 1375 625 1319.036 625 1250 C 625 1180.964 569.036 1125 500 1125 Z", { viewBox: "0 0 1000 1500", height: 17, width: 17 }),
|
||||
console: Icon("M14.8 2.7 9 3.1V47h3.3c1.7 0 6.2.3 10 .7l6.7.6V2l-4.2.2c-2.4.1-6.9.3-10 .5zm1.8 6.4c1 1.7-1.3 3.6-2.7 2.2C12.7 10.1 13.5 8 15 8c.5 0 1.2.5 1.6 1.1zM16 33c0 6-.4 10-1 10s-1-4-1-10 .4-10 1-10 1 4 1 10zm15-8v23.3l3.8-.7c2-.3 4.7-.6 6-.6H43V3h-2.2c-1.3 0-4-.3-6-.6L31 1.7V25z", { viewBox: "0 0 50 50" }),
|
||||
};
|
||||
type Platform = keyof typeof Icons;
|
||||
|
||||
@ -66,7 +66,7 @@ const PlatformIcon = ({ platform, status }: { platform: Platform, status: string
|
||||
|
||||
const getStatus = (id: string): Record<Platform, string> => PresenceStore.getState()?.clientStatuses?.[id];
|
||||
|
||||
const PlatformIndicator = ({ user, wantMargin = true }: { user: User; wantMargin?: boolean; }) => {
|
||||
const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false }: { user: User; wantMargin?: boolean; wantTopMargin?: boolean; }) => {
|
||||
if (!user || user.bot) return null;
|
||||
|
||||
if (user.id === UserStore.getCurrentUser().id) {
|
||||
@ -110,10 +110,11 @@ const PlatformIndicator = ({ user, wantMargin = true }: { user: User; wantMargin
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
marginLeft: wantMargin ? 4 : 0,
|
||||
verticalAlign: "top",
|
||||
position: "relative",
|
||||
top: wantMargin ? 1 : 0,
|
||||
top: wantTopMargin ? 2 : 0,
|
||||
padding: !wantMargin ? 1 : 0,
|
||||
gap: 2
|
||||
}}
|
||||
@ -150,7 +151,7 @@ const indicatorLocations = {
|
||||
description: "Inside messages",
|
||||
onEnable: () => addDecoration("platform-indicator", props =>
|
||||
<ErrorBoundary noop>
|
||||
<PlatformIndicator user={props.message?.author} />
|
||||
<PlatformIndicator user={props.message?.author} wantTopMargin={true} />
|
||||
</ErrorBoundary>
|
||||
),
|
||||
onDisable: () => removeDecoration("platform-indicator")
|
||||
|
@ -26,10 +26,12 @@ import { settings } from "../settings";
|
||||
|
||||
const styles: Record<string, string> = findByPropsLazy("timestampInline");
|
||||
|
||||
const AUTO_MODERATION_ACTION = 24;
|
||||
|
||||
function shouldShow(message: Message): boolean {
|
||||
if (!settings.store.showInMessages)
|
||||
return false;
|
||||
if (message.author.bot || message.author.system)
|
||||
if (message.author.bot || message.author.system || message.type === AUTO_MODERATION_ACTION)
|
||||
return false;
|
||||
if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
||||
return false;
|
||||
|
@ -17,28 +17,44 @@
|
||||
*/
|
||||
|
||||
import { classes } from "@utils/misc";
|
||||
import { LazyComponent } from "@utils/react";
|
||||
import { findByProps } from "@webpack";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Tooltip } from "@webpack/common";
|
||||
|
||||
export default LazyComponent(() => {
|
||||
const { button, dangerous } = findByProps("button", "wrapper", "disabled", "separator");
|
||||
const iconClasses = findByPropsLazy("button", "wrapper", "disabled", "separator");
|
||||
|
||||
return function MessageButton(props) {
|
||||
return props.type === "delete"
|
||||
? (
|
||||
<div className={classes(button, dangerous)} aria-label="Delete Review" onClick={props.callback}>
|
||||
<svg aria-hidden="false" width="16" height="16" viewBox="0 0 20 20">
|
||||
<path fill="currentColor" d="M15 3.999V2H9V3.999H3V5.999H21V3.999H15Z"></path>
|
||||
<path fill="currentColor" d="M5 6.99902V18.999C5 20.101 5.897 20.999 7 20.999H17C18.103 20.999 19 20.101 19 18.999V6.99902H5ZM11 17H9V11H11V17ZM15 17H13V11H15V17Z"></path>
|
||||
export function DeleteButton({ onClick }: { onClick(): void; }) {
|
||||
return (
|
||||
<Tooltip text="Delete Review">
|
||||
{props => (
|
||||
<div
|
||||
{...props}
|
||||
className={classes(iconClasses.button, iconClasses.dangerous)}
|
||||
onClick={onClick}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 20 20">
|
||||
<path fill="currentColor" d="M15 3.999V2H9V3.999H3V5.999H21V3.999H15Z" />
|
||||
<path fill="currentColor" d="M5 6.99902V18.999C5 20.101 5.897 20.999 7 20.999H17C18.103 20.999 19 20.101 19 18.999V6.99902H5ZM11 17H9V11H11V17ZM15 17H13V11H15V17Z" />
|
||||
</svg>
|
||||
</div>
|
||||
)
|
||||
: (
|
||||
<div className={button} aria-label="Report Review" onClick={() => props.callback()}>
|
||||
<svg aria-hidden="false" width="16" height="16" viewBox="0 0 20 20">
|
||||
<path fill="currentColor" d="M20,6.002H14V3.002C14,2.45 13.553,2.002 13,2.002H4C3.447,2.002 3,2.45 3,3.002V22.002H5V14.002H10.586L8.293,16.295C8.007,16.581 7.922,17.011 8.076,17.385C8.23,17.759 8.596,18.002 9,18.002H20C20.553,18.002 21,17.554 21,17.002V7.002C21,6.45 20.553,6.002 20,6.002Z"></path>
|
||||
)}
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export function ReportButton({ onClick }: { onClick(): void; }) {
|
||||
return (
|
||||
<Tooltip text="Report Review">
|
||||
{props => (
|
||||
<div
|
||||
{...props}
|
||||
className={iconClasses.button}
|
||||
onClick={onClick}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 20 20">
|
||||
<path fill="currentColor" d="M20,6.002H14V3.002C14,2.45 13.553,2.002 13,2.002H4C3.447,2.002 3,2.45 3,3.002V22.002H5V14.002H10.586L8.293,16.295C8.007,16.581 7.922,17.011 8.076,17.385C8.23,17.759 8.596,18.002 9,18.002H20C20.553,18.002 21,17.554 21,17.002V7.002C21,6.45 20.553,6.002 20,6.002Z" />
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
});
|
||||
)}
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
@ -18,7 +18,8 @@
|
||||
|
||||
import { MaskedLinkStore, Tooltip } from "@webpack/common";
|
||||
|
||||
import { Badge } from "../entities/Badge";
|
||||
import { Badge } from "../entities";
|
||||
import { cl } from "../utils";
|
||||
|
||||
export default function ReviewBadge(badge: Badge) {
|
||||
return (
|
||||
@ -26,13 +27,13 @@ export default function ReviewBadge(badge: Badge) {
|
||||
text={badge.name}>
|
||||
{({ onMouseEnter, onMouseLeave }) => (
|
||||
<img
|
||||
className={cl("badge")}
|
||||
width="24px"
|
||||
height="24px"
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
src={badge.icon}
|
||||
alt={badge.description}
|
||||
style={{ verticalAlign: "middle", marginLeft: "4px" }}
|
||||
onClick={() =>
|
||||
MaskedLinkStore.openUntrustedLink({
|
||||
href: badge.redirectURL,
|
||||
|
@ -16,16 +16,16 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { classes } from "@utils/misc";
|
||||
import { LazyComponent } from "@utils/react";
|
||||
import { filters, findBulk } from "@webpack";
|
||||
import { Alerts, moment, Timestamp, UserStore } from "@webpack/common";
|
||||
|
||||
import { Review } from "../entities/Review";
|
||||
import { deleteReview, reportReview } from "../Utils/ReviewDBAPI";
|
||||
import { canDeleteReview, openUserProfileModal, showToast } from "../Utils/Utils";
|
||||
import MessageButton from "./MessageButton";
|
||||
import { Review, ReviewType } from "../entities";
|
||||
import { deleteReview, reportReview } from "../reviewDbApi";
|
||||
import { settings } from "../settings";
|
||||
import { canDeleteReview, cl, openUserProfileModal, showToast } from "../utils";
|
||||
import { DeleteButton, ReportButton } from "./MessageButton";
|
||||
import ReviewBadge from "./ReviewBadge";
|
||||
|
||||
export default LazyComponent(() => {
|
||||
@ -36,11 +36,13 @@ export default LazyComponent(() => {
|
||||
{ container, isHeader },
|
||||
{ avatar, clickable, username, messageContent, wrapper, cozy },
|
||||
buttonClasses,
|
||||
botTag
|
||||
] = findBulk(
|
||||
p("cozyMessage"),
|
||||
p("container", "isHeader"),
|
||||
p("avatar", "zalgo"),
|
||||
p("button", "wrapper", "selected"),
|
||||
p("botTag")
|
||||
);
|
||||
|
||||
const dateFormat = new Intl.DateTimeFormat();
|
||||
@ -79,21 +81,21 @@ export default LazyComponent(() => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classes(cozyMessage, wrapper, message, groupStart, cozy, "user-review")} style={
|
||||
<div className={classes(cozyMessage, wrapper, message, groupStart, cozy, cl("review"))} style={
|
||||
{
|
||||
marginLeft: "0px",
|
||||
paddingLeft: "52px",
|
||||
paddingLeft: "52px", // wth is this
|
||||
paddingRight: "16px"
|
||||
}
|
||||
}>
|
||||
|
||||
<div>
|
||||
<img
|
||||
className={classes(avatar, clickable)}
|
||||
onClick={openModal}
|
||||
src={review.sender.profilePhoto || "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
|
||||
style={{ left: "0px" }}
|
||||
/>
|
||||
<img
|
||||
className={classes(avatar, clickable)}
|
||||
onClick={openModal}
|
||||
src={review.sender.profilePhoto || "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
|
||||
style={{ left: "0px" }}
|
||||
/>
|
||||
<div style={{ display: "inline-flex", justifyContent: "center", alignItems: "center" }}>
|
||||
<span
|
||||
className={classes(clickable, username)}
|
||||
style={{ color: "var(--channels-default)", fontSize: "14px" }}
|
||||
@ -101,32 +103,45 @@ export default LazyComponent(() => {
|
||||
>
|
||||
{review.sender.username}
|
||||
</span>
|
||||
{review.sender.badges.map(badge => <ReviewBadge {...badge} />)}
|
||||
|
||||
{
|
||||
!Settings.plugins.ReviewDB.hideTimestamps && (
|
||||
<Timestamp timestamp={moment(review.timestamp * 1000)} >
|
||||
{dateFormat.format(review.timestamp * 1000)}
|
||||
</Timestamp>)
|
||||
}
|
||||
{review.type === ReviewType.System && (
|
||||
<span
|
||||
className={classes(botTag.botTagVerified, botTag.botTagRegular, botTag.botTag, botTag.px, botTag.rem)}
|
||||
style={{ marginLeft: "4px" }}>
|
||||
<span className={botTag.botText}>
|
||||
System
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{review.sender.badges.map(badge => <ReviewBadge {...badge} />)}
|
||||
|
||||
<p
|
||||
className={classes(messageContent)}
|
||||
style={{ fontSize: 15, marginTop: 4, color: "var(--text-normal)" }}
|
||||
>
|
||||
{review.comment}
|
||||
</p>
|
||||
{
|
||||
!settings.store.hideTimestamps && review.type !== ReviewType.System && (
|
||||
<Timestamp timestamp={moment(review.timestamp * 1000)} >
|
||||
{dateFormat.format(review.timestamp * 1000)}
|
||||
</Timestamp>)
|
||||
}
|
||||
|
||||
<p
|
||||
className={classes(messageContent)}
|
||||
style={{ fontSize: 15, marginTop: 4, color: "var(--text-normal)" }}
|
||||
>
|
||||
{review.comment}
|
||||
</p>
|
||||
{review.id !== 0 && (
|
||||
<div className={classes(container, isHeader, buttons)} style={{
|
||||
padding: "0px",
|
||||
}}>
|
||||
<div className={buttonClasses.wrapper} >
|
||||
<MessageButton type="report" callback={reportRev} />
|
||||
<ReportButton onClick={reportRev} />
|
||||
|
||||
{canDeleteReview(review, UserStore.getCurrentUser().id) && (
|
||||
<MessageButton type="delete" callback={delReview} />
|
||||
<DeleteButton onClick={delReview} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
104
src/plugins/reviewDB/components/ReviewModal.tsx
Normal file
104
src/plugins/reviewDB/components/ReviewModal.tsx
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { useForceUpdater } from "@utils/react";
|
||||
import { Paginator, Text, useRef, useState } from "@webpack/common";
|
||||
|
||||
import { Response, REVIEWS_PER_PAGE } from "../reviewDbApi";
|
||||
import { settings } from "../settings";
|
||||
import { cl } from "../utils";
|
||||
import ReviewComponent from "./ReviewComponent";
|
||||
import ReviewsView, { ReviewsInputComponent } from "./ReviewsView";
|
||||
|
||||
function Modal({ modalProps, discordId, name }: { modalProps: any; discordId: string; name: string; }) {
|
||||
const [data, setData] = useState<Response>();
|
||||
const [signal, refetch] = useForceUpdater(true);
|
||||
const [page, setPage] = useState(1);
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
const reviewCount = data?.reviewCount;
|
||||
const ownReview = data?.reviews.find(r => r.sender.discordID === settings.store.user?.discordID);
|
||||
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<ModalRoot {...modalProps} size={ModalSize.MEDIUM}>
|
||||
<ModalHeader>
|
||||
<Text variant="heading-lg/semibold" className={cl("modal-header")}>
|
||||
{name}'s Reviews
|
||||
{!!reviewCount && <span> ({reviewCount} Reviews)</span>}
|
||||
</Text>
|
||||
<ModalCloseButton onClick={modalProps.onClose} />
|
||||
</ModalHeader>
|
||||
|
||||
<ModalContent scrollerRef={ref}>
|
||||
<div className={cl("modal-reviews")}>
|
||||
<ReviewsView
|
||||
discordId={discordId}
|
||||
name={name}
|
||||
page={page}
|
||||
refetchSignal={signal}
|
||||
onFetchReviews={setData}
|
||||
scrollToTop={() => ref.current?.scrollTo({ top: 0, behavior: "smooth" })}
|
||||
hideOwnReview
|
||||
/>
|
||||
</div>
|
||||
</ModalContent>
|
||||
|
||||
<ModalFooter className={cl("modal-footer")}>
|
||||
<div>
|
||||
{ownReview && (
|
||||
<ReviewComponent
|
||||
refetch={refetch}
|
||||
review={ownReview}
|
||||
/>
|
||||
)}
|
||||
<ReviewsInputComponent
|
||||
isAuthor={ownReview != null}
|
||||
discordId={discordId}
|
||||
name={name}
|
||||
refetch={refetch}
|
||||
/>
|
||||
|
||||
{!!reviewCount && (
|
||||
<Paginator
|
||||
currentPage={page}
|
||||
maxVisiblePages={5}
|
||||
pageSize={REVIEWS_PER_PAGE}
|
||||
totalCount={reviewCount}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</ModalFooter>
|
||||
</ModalRoot>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
export function openReviewsModal(discordId: string, name: string) {
|
||||
openModal(props => (
|
||||
<Modal
|
||||
modalProps={props}
|
||||
discordId={discordId}
|
||||
name={name}
|
||||
/>
|
||||
));
|
||||
}
|
@ -16,42 +16,113 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { classes } from "@utils/misc";
|
||||
import { useAwaiter } from "@utils/react";
|
||||
import { useAwaiter, useForceUpdater } from "@utils/react";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Forms, React, Text, UserStore } from "@webpack/common";
|
||||
import { Forms, React, UserStore } from "@webpack/common";
|
||||
import type { KeyboardEvent } from "react";
|
||||
|
||||
import { addReview, getReviews } from "../Utils/ReviewDBAPI";
|
||||
import { authorize, showToast } from "../Utils/Utils";
|
||||
import { Review } from "../entities";
|
||||
import { addReview, getReviews, Response, REVIEWS_PER_PAGE } from "../reviewDbApi";
|
||||
import { settings } from "../settings";
|
||||
import { authorize, cl, showToast } from "../utils";
|
||||
import ReviewComponent from "./ReviewComponent";
|
||||
|
||||
const Classes = findByPropsLazy("inputDefault", "editable");
|
||||
|
||||
export default function ReviewsView({ userId }: { userId: string; }) {
|
||||
const { token } = Settings.plugins.ReviewDB;
|
||||
const [refetchCount, setRefetchCount] = React.useState(0);
|
||||
const [reviews, _, isLoading] = useAwaiter(() => getReviews(userId), {
|
||||
fallbackValue: [],
|
||||
deps: [refetchCount],
|
||||
interface UserProps {
|
||||
discordId: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface Props extends UserProps {
|
||||
onFetchReviews(data: Response): void;
|
||||
refetchSignal?: unknown;
|
||||
showInput?: boolean;
|
||||
page?: number;
|
||||
scrollToTop?(): void;
|
||||
hideOwnReview?: boolean;
|
||||
}
|
||||
|
||||
export default function ReviewsView({
|
||||
discordId,
|
||||
name,
|
||||
onFetchReviews,
|
||||
refetchSignal,
|
||||
scrollToTop,
|
||||
page = 1,
|
||||
showInput = false,
|
||||
hideOwnReview = false,
|
||||
}: Props) {
|
||||
const [signal, refetch] = useForceUpdater(true);
|
||||
|
||||
const [reviewData] = useAwaiter(() => getReviews(discordId, (page - 1) * REVIEWS_PER_PAGE), {
|
||||
fallbackValue: null,
|
||||
deps: [refetchSignal, signal, page],
|
||||
onSuccess: data => {
|
||||
scrollToTop?.();
|
||||
onFetchReviews(data!);
|
||||
}
|
||||
});
|
||||
const username = UserStore.getUser(userId)?.username ?? "";
|
||||
|
||||
const dirtyRefetch = () => setRefetchCount(refetchCount + 1);
|
||||
if (!reviewData) return null;
|
||||
|
||||
if (isLoading) return null;
|
||||
return (
|
||||
<>
|
||||
<ReviewList
|
||||
refetch={refetch}
|
||||
reviews={reviewData!.reviews}
|
||||
hideOwnReview={hideOwnReview}
|
||||
/>
|
||||
|
||||
{showInput && (
|
||||
<ReviewsInputComponent
|
||||
name={name}
|
||||
discordId={discordId}
|
||||
refetch={refetch}
|
||||
isAuthor={reviewData!.reviews?.some(r => r.sender.discordID === UserStore.getCurrentUser().id)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ReviewList({ refetch, reviews, hideOwnReview }: { refetch(): void; reviews: Review[]; hideOwnReview: boolean; }) {
|
||||
const myId = UserStore.getCurrentUser().id;
|
||||
|
||||
return (
|
||||
<div className={cl("view")}>
|
||||
{reviews?.map(review =>
|
||||
(review.sender.discordID !== myId || !hideOwnReview) &&
|
||||
<ReviewComponent
|
||||
key={review.id}
|
||||
review={review}
|
||||
refetch={refetch}
|
||||
/>
|
||||
)}
|
||||
|
||||
{reviews?.length === 0 && (
|
||||
<Forms.FormText className={cl("placeholder")}>
|
||||
Looks like nobody reviewed this user yet. You could be the first!
|
||||
</Forms.FormText>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ReviewsInputComponent({ discordId, isAuthor, refetch, name }: { discordId: string, name: string; isAuthor: boolean; refetch(): void; }) {
|
||||
const { token } = settings.store;
|
||||
|
||||
function onKeyPress({ key, target }: KeyboardEvent<HTMLTextAreaElement>) {
|
||||
if (key === "Enter") {
|
||||
addReview({
|
||||
userid: userId,
|
||||
userid: discordId,
|
||||
comment: (target as HTMLInputElement).value,
|
||||
star: -1
|
||||
}).then(res => {
|
||||
if (res?.success) {
|
||||
(target as HTMLInputElement).value = ""; // clear the input
|
||||
dirtyRefetch();
|
||||
refetch();
|
||||
} else if (res?.message) {
|
||||
showToast(res.message);
|
||||
}
|
||||
@ -60,61 +131,27 @@ export default function ReviewsView({ userId }: { userId: string; }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="vc-reviewdb-view">
|
||||
<Text
|
||||
tag="h2"
|
||||
variant="eyebrow"
|
||||
style={{
|
||||
marginBottom: "8px",
|
||||
color: "var(--header-primary)"
|
||||
}}
|
||||
>
|
||||
User Reviews
|
||||
</Text>
|
||||
{reviews?.map(review =>
|
||||
<ReviewComponent
|
||||
key={review.id}
|
||||
review={review}
|
||||
refetch={dirtyRefetch}
|
||||
/>
|
||||
)}
|
||||
{reviews?.length === 0 && (
|
||||
<Forms.FormText style={{ paddingRight: "12px", paddingTop: "0px", paddingLeft: "0px", paddingBottom: "4px", fontWeight: "bold", fontStyle: "italic" }}>
|
||||
Looks like nobody reviewed this user yet. You could be the first!
|
||||
</Forms.FormText>
|
||||
)}
|
||||
<textarea
|
||||
className={classes(Classes.inputDefault, "enter-comment")}
|
||||
onKeyDownCapture={e => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault(); // prevent newlines
|
||||
}
|
||||
}}
|
||||
placeholder={
|
||||
token
|
||||
? (reviews?.some(r => r.sender.discordID === UserStore.getCurrentUser().id)
|
||||
? `Update review for @${username}`
|
||||
: `Review @${username}`)
|
||||
: "You need to authorize to review users!"
|
||||
<textarea
|
||||
className={classes(Classes.inputDefault, "enter-comment", cl("input"))}
|
||||
onKeyDownCapture={e => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault(); // prevent newlines
|
||||
}
|
||||
onKeyDown={onKeyPress}
|
||||
onClick={() => {
|
||||
if (!token) {
|
||||
showToast("Opening authorization window...");
|
||||
authorize();
|
||||
}
|
||||
}}
|
||||
|
||||
style={{
|
||||
marginTop: "6px",
|
||||
resize: "none",
|
||||
marginBottom: "12px",
|
||||
overflow: "hidden",
|
||||
background: "transparent",
|
||||
border: "1px solid var(--profile-message-input-border-color)",
|
||||
fontSize: "14px",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
}}
|
||||
placeholder={
|
||||
!token
|
||||
? "You need to authorize to review users!"
|
||||
: isAuthor
|
||||
? `Update review for @${name}`
|
||||
: `Review @${name}`
|
||||
}
|
||||
onKeyDown={onKeyPress}
|
||||
onClick={() => {
|
||||
if (!token) {
|
||||
showToast("Opening authorization window...");
|
||||
authorize();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -22,23 +22,55 @@ export const enum UserType {
|
||||
Admin = 1
|
||||
}
|
||||
|
||||
export const enum ReviewType {
|
||||
User = 0,
|
||||
Server = 1,
|
||||
Support = 2,
|
||||
System = 3
|
||||
}
|
||||
|
||||
export interface Badge {
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
redirectURL: string;
|
||||
type: number;
|
||||
}
|
||||
|
||||
export interface BanInfo {
|
||||
id: string;
|
||||
discordID: string;
|
||||
reviewID: number;
|
||||
reviewContent: string;
|
||||
banEndDate: string;
|
||||
banEndDate: number;
|
||||
}
|
||||
|
||||
export interface ReviewDBUser {
|
||||
ID: number
|
||||
discordID: string
|
||||
username: string
|
||||
profilePhoto: string
|
||||
clientMod: string
|
||||
warningCount: number
|
||||
badges: any[]
|
||||
banInfo: BanInfo | null
|
||||
lastReviewID: number
|
||||
type: UserType
|
||||
ID: number;
|
||||
discordID: string;
|
||||
username: string;
|
||||
profilePhoto: string;
|
||||
clientMod: string;
|
||||
warningCount: number;
|
||||
badges: any[];
|
||||
banInfo: BanInfo | null;
|
||||
lastReviewID: number;
|
||||
type: UserType;
|
||||
}
|
||||
|
||||
export interface ReviewAuthor {
|
||||
id: number,
|
||||
discordID: string,
|
||||
username: string,
|
||||
profilePhoto: string,
|
||||
badges: Badge[];
|
||||
}
|
||||
|
||||
export interface Review {
|
||||
comment: string,
|
||||
id: number,
|
||||
star: number,
|
||||
sender: ReviewAuthor,
|
||||
timestamp: number;
|
||||
type?: ReviewType;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2022 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
export interface Badge {
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
redirectURL : string;
|
||||
type: number;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2022 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Badge } from "./Badge";
|
||||
|
||||
export interface Sender {
|
||||
id : number,
|
||||
discordID: string,
|
||||
username: string,
|
||||
profilePhoto: string,
|
||||
badges: Badge[]
|
||||
}
|
||||
|
||||
export interface Review {
|
||||
comment: string,
|
||||
id: number,
|
||||
star: number,
|
||||
sender: Sender,
|
||||
timestamp: number
|
||||
}
|
@ -18,23 +18,40 @@
|
||||
|
||||
import "./style.css";
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import ExpandableHeader from "@components/ExpandableHeader";
|
||||
import { OpenExternalIcon } from "@components/Icons";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Alerts, Button } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Alerts, Menu, useState } from "@webpack/common";
|
||||
import { Guild, User } from "discord-types/general";
|
||||
|
||||
import { openReviewsModal } from "./components/ReviewModal";
|
||||
import ReviewsView from "./components/ReviewsView";
|
||||
import { UserType } from "./entities/User";
|
||||
import { getCurrentUserInfo } from "./Utils/ReviewDBAPI";
|
||||
import { authorize, showToast } from "./Utils/Utils";
|
||||
import { UserType } from "./entities";
|
||||
import { getCurrentUserInfo } from "./reviewDbApi";
|
||||
import { settings } from "./settings";
|
||||
import { showToast } from "./utils";
|
||||
|
||||
const guildPopoutPatch: NavContextMenuPatchCallback = (children, props: { guild: Guild, onClose(): void; }) => () => {
|
||||
children.push(
|
||||
<Menu.MenuItem
|
||||
label="View Reviews"
|
||||
id="vc-rdb-server-reviews"
|
||||
icon={OpenExternalIcon}
|
||||
action={() => openReviewsModal(props.guild.id, props.guild.name)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default definePlugin({
|
||||
name: "ReviewDB",
|
||||
description: "Review other users (Adds a new settings to profiles)",
|
||||
authors: [Devs.mantikafasi, Devs.Ven],
|
||||
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: "disableBorderColor:!0",
|
||||
@ -45,100 +62,86 @@ export default definePlugin({
|
||||
}
|
||||
],
|
||||
|
||||
options: {
|
||||
authorize: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "Authorize with ReviewDB",
|
||||
component: () => (
|
||||
<Button onClick={authorize}>
|
||||
Authorize with ReviewDB
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
notifyReviews: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Notify about new reviews on startup",
|
||||
default: true,
|
||||
},
|
||||
showWarning: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Display warning to be respectful at the top of the reviews list",
|
||||
default: true,
|
||||
},
|
||||
hideTimestamps: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Hide timestamps on reviews",
|
||||
default: false,
|
||||
},
|
||||
website: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "ReviewDB website",
|
||||
component: () => (
|
||||
<Button onClick={() => {
|
||||
window.open("https://reviewdb.mantikafasi.dev");
|
||||
}}>
|
||||
ReviewDB website
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
supportServer: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "ReviewDB Support Server",
|
||||
component: () => (
|
||||
<Button onClick={() => {
|
||||
window.open("https://discord.gg/eWPBSbvznt");
|
||||
}}>
|
||||
ReviewDB Support Server
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
},
|
||||
|
||||
async start() {
|
||||
const settings = Settings.plugins.ReviewDB;
|
||||
if (!settings.notifyReviews || !settings.token) return;
|
||||
const s = settings.store;
|
||||
const { token, lastReviewId, notifyReviews } = s;
|
||||
|
||||
if (!notifyReviews || !token) return;
|
||||
|
||||
setTimeout(async () => {
|
||||
const user = await getCurrentUserInfo(settings.token);
|
||||
if (settings.lastReviewId < user.lastReviewID) {
|
||||
settings.lastReviewId = user.lastReviewID;
|
||||
const user = await getCurrentUserInfo(token);
|
||||
if (lastReviewId && lastReviewId < user.lastReviewID) {
|
||||
s.lastReviewId = user.lastReviewID;
|
||||
if (user.lastReviewID !== 0)
|
||||
showToast("You have new reviews on your profile!");
|
||||
}
|
||||
|
||||
if (user.banInfo) {
|
||||
const endDate = new Date(user.banInfo.banEndDate);
|
||||
if (endDate > new Date() && (settings.user?.banInfo?.banEndDate ?? 0) < endDate) {
|
||||
addContextMenuPatch("guild-header-popout", guildPopoutPatch);
|
||||
|
||||
if (user.banInfo) {
|
||||
const endDate = new Date(user.banInfo.banEndDate).getTime();
|
||||
if (endDate > Date.now() && (s.user?.banInfo?.banEndDate ?? 0) < endDate) {
|
||||
Alerts.show({
|
||||
title: "You have been banned from ReviewDB",
|
||||
body: <>
|
||||
<p>
|
||||
You are banned from ReviewDB {(user.type === UserType.Banned) ? "permanently" : "until " + endDate.toLocaleString()}
|
||||
</p>
|
||||
<p>
|
||||
Offending Review: {user.banInfo.reviewContent}
|
||||
</p>
|
||||
<p>
|
||||
Continued offenses will result in a permanent ban.
|
||||
</p>
|
||||
</>,
|
||||
body: (
|
||||
<>
|
||||
<p>
|
||||
You are banned from ReviewDB {
|
||||
user.type === UserType.Banned
|
||||
? "permanently"
|
||||
: "until " + endDate.toLocaleString()
|
||||
}
|
||||
</p>
|
||||
{user.banInfo.reviewContent && (
|
||||
<p>Offending Review: {user.banInfo.reviewContent}</p>
|
||||
)}
|
||||
<p>Continued offenses will result in a permanent ban.</p>
|
||||
</>
|
||||
),
|
||||
cancelText: "Appeal",
|
||||
confirmText: "Ok",
|
||||
onCancel: () => {
|
||||
window.open("https://forms.gle/Thj3rDYaMdKoMMuq6");
|
||||
}
|
||||
onCancel: () =>
|
||||
VencordNative.native.openExternal(
|
||||
"https://reviewdb.mantikafasi.dev/api/redirect?"
|
||||
+ new URLSearchParams({
|
||||
token: settings.store.token!,
|
||||
page: "dashboard/appeal"
|
||||
})
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
settings.user = user;
|
||||
s.user = user;
|
||||
}, 4000);
|
||||
},
|
||||
|
||||
getReviewsComponent: (user: User) => (
|
||||
<ErrorBoundary message="Failed to render Reviews">
|
||||
<ReviewsView userId={user.id} />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
stop() {
|
||||
removeContextMenuPatch("guild-header-popout", guildPopoutPatch);
|
||||
},
|
||||
|
||||
getReviewsComponent: ErrorBoundary.wrap((user: User) => {
|
||||
const [reviewCount, setReviewCount] = useState<number>();
|
||||
|
||||
return (
|
||||
<ExpandableHeader
|
||||
headerText="User Reviews"
|
||||
onMoreClick={() => openReviewsModal(user.id, user.username)}
|
||||
moreTooltipText={
|
||||
reviewCount && reviewCount > 50
|
||||
? `View all ${reviewCount} reviews`
|
||||
: "Open Review Modal"
|
||||
}
|
||||
onDropDownClick={state => settings.store.reviewsDropdownState = !state}
|
||||
defaultState={settings.store.reviewsDropdownState}
|
||||
>
|
||||
<ReviewsView
|
||||
discordId={user.id}
|
||||
name={user.username}
|
||||
onFetchReviews={r => setReviewCount(r.reviewCount)}
|
||||
showInput
|
||||
/>
|
||||
</ExpandableHeader>
|
||||
);
|
||||
}, { message: "Failed to render Reviews" })
|
||||
});
|
||||
|
@ -16,54 +16,74 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
|
||||
import { Review } from "../entities/Review";
|
||||
import { ReviewDBUser } from "../entities/User";
|
||||
import { authorize, showToast } from "./Utils";
|
||||
import { Review, ReviewDBUser } from "./entities";
|
||||
import { settings } from "./settings";
|
||||
import { authorize, showToast } from "./utils";
|
||||
|
||||
const API_URL = "https://manti.vendicated.dev";
|
||||
|
||||
const getToken = () => Settings.plugins.ReviewDB.token;
|
||||
export const REVIEWS_PER_PAGE = 50;
|
||||
|
||||
interface Response {
|
||||
export interface Response {
|
||||
success: boolean,
|
||||
message: string;
|
||||
reviews: Review[];
|
||||
updated: boolean;
|
||||
hasNextPage: boolean;
|
||||
reviewCount: number;
|
||||
}
|
||||
|
||||
const WarningFlag = 0b00000010;
|
||||
|
||||
export async function getReviews(id: string): Promise<Review[]> {
|
||||
var flags = 0;
|
||||
if (!Settings.plugins.ReviewDB.showWarning) flags |= WarningFlag;
|
||||
const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews?flags=${flags}`);
|
||||
export async function getReviews(id: string, offset = 0): Promise<Response> {
|
||||
let flags = 0;
|
||||
if (!settings.store.showWarning) flags |= WarningFlag;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
flags: String(flags),
|
||||
offset: String(offset)
|
||||
});
|
||||
const req = await fetch(`${API_URL}/api/reviewdb/users/${id}/reviews?${params}`);
|
||||
|
||||
const res = (req.status === 200)
|
||||
? await req.json() as Response
|
||||
: {
|
||||
success: false,
|
||||
message: "An Error occured while fetching reviews. Please try again later.",
|
||||
reviews: [],
|
||||
updated: false,
|
||||
hasNextPage: false,
|
||||
reviewCount: 0
|
||||
};
|
||||
|
||||
const res = (req.status === 200) ? await req.json() as Response : { success: false, message: "An Error occured while fetching reviews. Please try again later.", reviews: [], updated: false };
|
||||
if (!res.success) {
|
||||
showToast(res.message);
|
||||
return [
|
||||
{
|
||||
id: 0,
|
||||
comment: "An Error occured while fetching reviews. Please try again later.",
|
||||
star: 0,
|
||||
timestamp: 0,
|
||||
sender: {
|
||||
return {
|
||||
...res,
|
||||
reviews: [
|
||||
{
|
||||
id: 0,
|
||||
username: "Error",
|
||||
profilePhoto: "https://cdn.discordapp.com/attachments/1045394533384462377/1084900598035513447/646808599204593683.png?size=128",
|
||||
discordID: "0",
|
||||
badges: []
|
||||
comment: "An Error occured while fetching reviews. Please try again later.",
|
||||
star: 0,
|
||||
timestamp: 0,
|
||||
sender: {
|
||||
id: 0,
|
||||
username: "Error",
|
||||
profilePhoto: "https://cdn.discordapp.com/attachments/1045394533384462377/1084900598035513447/646808599204593683.png?size=128",
|
||||
discordID: "0",
|
||||
badges: []
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
}
|
||||
return res.reviews;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function addReview(review: any): Promise<Response | null> {
|
||||
review.token = getToken();
|
||||
review.token = settings.store.token;
|
||||
|
||||
if (!review.token) {
|
||||
showToast("Please authorize to add a review.");
|
||||
@ -93,7 +113,7 @@ export function deleteReview(id: number): Promise<Response> {
|
||||
Accept: "application/json",
|
||||
}),
|
||||
body: JSON.stringify({
|
||||
token: getToken(),
|
||||
token: settings.store.token,
|
||||
reviewid: id
|
||||
})
|
||||
}).then(r => r.json());
|
||||
@ -108,16 +128,16 @@ export async function reportReview(id: number) {
|
||||
}),
|
||||
body: JSON.stringify({
|
||||
reviewid: id,
|
||||
token: getToken()
|
||||
token: settings.store.token
|
||||
})
|
||||
}).then(r => r.json()) as Response;
|
||||
showToast(await res.message);
|
||||
|
||||
showToast(res.message);
|
||||
}
|
||||
|
||||
export function getCurrentUserInfo(token: string): Promise<ReviewDBUser> {
|
||||
return fetch(API_URL + "/api/reviewdb/users", {
|
||||
body: JSON.stringify({ token }),
|
||||
method: "POST",
|
||||
})
|
||||
.then(r => r.json());
|
||||
}).then(r => r.json());
|
||||
}
|
82
src/plugins/reviewDB/settings.tsx
Normal file
82
src/plugins/reviewDB/settings.tsx
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { OptionType } from "@utils/types";
|
||||
import { Button } from "@webpack/common";
|
||||
|
||||
import { ReviewDBUser } from "./entities";
|
||||
import { authorize } from "./utils";
|
||||
|
||||
export const settings = definePluginSettings({
|
||||
authorize: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "Authorize with ReviewDB",
|
||||
component: () => (
|
||||
<Button onClick={authorize}>
|
||||
Authorize with ReviewDB
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
notifyReviews: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Notify about new reviews on startup",
|
||||
default: true,
|
||||
},
|
||||
showWarning: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Display warning to be respectful at the top of the reviews list",
|
||||
default: true,
|
||||
},
|
||||
hideTimestamps: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Hide timestamps on reviews",
|
||||
default: false,
|
||||
},
|
||||
website: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "ReviewDB website",
|
||||
component: () => (
|
||||
<Button onClick={() => {
|
||||
let url = "https://reviewdb.mantikafasi.dev/";
|
||||
if (settings.store.token)
|
||||
url += "/api/redirect?token=" + encodeURIComponent(settings.store.token);
|
||||
|
||||
VencordNative.native.openExternal(url);
|
||||
}}>
|
||||
ReviewDB website
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
supportServer: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "ReviewDB Support Server",
|
||||
component: () => (
|
||||
<Button onClick={() => {
|
||||
VencordNative.native.openExternal("https://discord.gg/eWPBSbvznt");
|
||||
}}>
|
||||
ReviewDB Support Server
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
}).withPrivateSettings<{
|
||||
token?: string;
|
||||
user?: ReviewDBUser;
|
||||
lastReviewId?: number;
|
||||
reviewsDropdownState?: boolean;
|
||||
}>();
|
@ -1,3 +1,51 @@
|
||||
[class|="section"]:not([class|="lastSection"]) + .vc-reviewdb-view {
|
||||
[class|="section"]:not([class|="lastSection"]) + .vc-rdb-view {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.vc-rdb-badge {
|
||||
vertical-align: middle;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.vc-rdb-input {
|
||||
margin-top: 6px;
|
||||
margin-bottom: 12px;
|
||||
resize: none;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
border: 1px solid var(--profile-message-input-border-color);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.vc-rdb-placeholder {
|
||||
margin-bottom: 4px;
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.vc-rdb-modal-footer {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.vc-rdb-modal-footer > div {
|
||||
width: 100%;
|
||||
margin: 6px 16px;
|
||||
}
|
||||
|
||||
.vc-rdb-modal-footer .vc-rdb-input {
|
||||
margin-bottom: 0;
|
||||
background: var(--input-background);
|
||||
}
|
||||
|
||||
.vc-rdb-modal-footer [class|="pageControlContainer"] {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.vc-rdb-modal-header {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.vc-rdb-modal-reviews {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
@ -16,14 +16,16 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { classNameFactory } from "@api/Styles";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { openModal } from "@utils/modal";
|
||||
import { findByProps } from "@webpack";
|
||||
import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common";
|
||||
|
||||
import { Review } from "../entities/Review";
|
||||
import { UserType } from "../entities/User";
|
||||
import { Review, UserType } from "./entities";
|
||||
import { settings } from "./settings";
|
||||
|
||||
export const cl = classNameFactory("vc-rdb-");
|
||||
|
||||
export async function openUserProfileModal(userId: string) {
|
||||
await UserUtils.fetchUser(userId);
|
||||
@ -57,7 +59,7 @@ export function authorize(callback?: any) {
|
||||
});
|
||||
const { token, success } = await res.json();
|
||||
if (success) {
|
||||
Settings.plugins.ReviewDB.token = token;
|
||||
settings.store.token = token;
|
||||
showToast("Successfully logged in!");
|
||||
callback?.();
|
||||
} else if (res.status === 1) {
|
||||
@ -82,8 +84,9 @@ export function showToast(text: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
|
||||
|
||||
export function canDeleteReview(review: Review, userId: string) {
|
||||
if (review.sender.discordID === userId || Settings.plugins.ReviewDB.user?.type === UserType.Admin) return true;
|
||||
return (
|
||||
review.sender.discordID === userId
|
||||
|| settings.store.user?.type === UserType.Admin
|
||||
);
|
||||
}
|
@ -38,7 +38,7 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { messag
|
||||
// dms and group chats
|
||||
const dmGroup = findGroupChildrenByChildId("pin", children);
|
||||
if (dmGroup && !dmGroup.some(child => child?.props?.id === "reply")) {
|
||||
const pinIndex = dmGroup.findIndex(c => c.props.id === "pin");
|
||||
const pinIndex = dmGroup.findIndex(c => c?.props.id === "pin");
|
||||
return dmGroup.splice(pinIndex + 1, 0, (
|
||||
<Menu.MenuItem
|
||||
id="reply"
|
||||
|
@ -16,15 +16,18 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { LazyComponent } from "@utils/react";
|
||||
import { formatDuration } from "@utils/text";
|
||||
import { find, findByPropsLazy, findStoreLazy } from "@webpack";
|
||||
import { FluxDispatcher, GuildMemberStore, GuildStore, moment, Parser, PermissionStore, SnowflakeUtils, Text, Timestamp, Tooltip } from "@webpack/common";
|
||||
import { find, findByPropsLazy } from "@webpack";
|
||||
import { EmojiStore, FluxDispatcher, GuildMemberStore, GuildStore, moment, Parser, PermissionStore, SnowflakeUtils, Text, Timestamp, Tooltip, useEffect, useState } from "@webpack/common";
|
||||
import type { Channel } from "discord-types/general";
|
||||
import type { ComponentType } from "react";
|
||||
|
||||
import { VIEW_CHANNEL } from "..";
|
||||
import openRolesAndUsersPermissionsModal, { PermissionType, RoleOrUserPermission } from "../../permissionsViewer/components/RolesAndUsersPermissions";
|
||||
import { sortPermissionOverwrites } from "../../permissionsViewer/utils";
|
||||
import { settings, VIEW_CHANNEL } from "..";
|
||||
|
||||
enum SortOrderTypes {
|
||||
LATEST_ACTIVITY = 0,
|
||||
@ -92,7 +95,6 @@ const TagComponent = LazyComponent(() => find(m => {
|
||||
return code.includes(".Messages.FORUM_TAG_A11Y_FILTER_BY_TAG") && !code.includes("increasedActivityPill");
|
||||
}));
|
||||
|
||||
const EmojiStore = findStoreLazy("EmojiStore");
|
||||
const EmojiParser = findByPropsLazy("convertSurrogateToName");
|
||||
const EmojiUtils = findByPropsLazy("getURL", "buildEmojiReactionColorsPlatformed");
|
||||
|
||||
@ -124,6 +126,9 @@ const VideoQualityModesToNames = {
|
||||
const HiddenChannelLogo = "/assets/433e3ec4319a9d11b0cbe39342614982.svg";
|
||||
|
||||
function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
||||
const [viewAllowedUsersAndRoles, setViewAllowedUsersAndRoles] = useState(settings.store.defaultAllowedUsersAndRolesDropdownState);
|
||||
const [permissions, setPermissions] = useState<RoleOrUserPermission[]>([]);
|
||||
|
||||
const {
|
||||
type,
|
||||
topic,
|
||||
@ -140,27 +145,39 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
||||
bitrate,
|
||||
rtcRegion,
|
||||
videoQualityMode,
|
||||
permissionOverwrites
|
||||
permissionOverwrites,
|
||||
guild_id
|
||||
} = channel;
|
||||
|
||||
const membersToFetch: Array<string> = [];
|
||||
useEffect(() => {
|
||||
const membersToFetch: Array<string> = [];
|
||||
|
||||
const guildOwnerId = GuildStore.getGuild(channel.guild_id).ownerId;
|
||||
if (!GuildMemberStore.getMember(channel.guild_id, guildOwnerId)) membersToFetch.push(guildOwnerId);
|
||||
const guildOwnerId = GuildStore.getGuild(guild_id).ownerId;
|
||||
if (!GuildMemberStore.getMember(guild_id, guildOwnerId)) membersToFetch.push(guildOwnerId);
|
||||
|
||||
Object.values(permissionOverwrites).forEach(({ type, id: userId }) => {
|
||||
if (type === 1) {
|
||||
if (!GuildMemberStore.getMember(channel.guild_id, userId)) membersToFetch.push(userId);
|
||||
}
|
||||
});
|
||||
|
||||
if (membersToFetch.length > 0) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "GUILD_MEMBERS_REQUEST",
|
||||
guildIds: [channel.guild_id],
|
||||
userIds: membersToFetch
|
||||
Object.values(permissionOverwrites).forEach(({ type, id: userId }) => {
|
||||
if (type === 1 && !GuildMemberStore.getMember(guild_id, userId)) {
|
||||
membersToFetch.push(userId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (membersToFetch.length > 0) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "GUILD_MEMBERS_REQUEST",
|
||||
guildIds: [guild_id],
|
||||
userIds: membersToFetch
|
||||
});
|
||||
}
|
||||
|
||||
if (Settings.plugins.PermissionsViewer.enabled) {
|
||||
setPermissions(sortPermissionOverwrites(Object.values(permissionOverwrites).map(overwrite => ({
|
||||
type: overwrite.type as PermissionType,
|
||||
id: overwrite.id,
|
||||
overwriteAllow: overwrite.allow,
|
||||
overwriteDeny: overwrite.deny
|
||||
})), guild_id));
|
||||
}
|
||||
}, [channelId]);
|
||||
|
||||
return (
|
||||
<div className={ChatScrollClasses.auto + " " + ChatScrollClasses.customTheme + " " + ChatClasses.chatContent + " " + "shc-lock-screen-outer-container"}>
|
||||
@ -182,7 +199,7 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
||||
aria-hidden={true}
|
||||
role="img"
|
||||
>
|
||||
<path d="M.7 43.05 24 2.85l23.3 40.2Zm23.55-6.25q.75 0 1.275-.525.525-.525.525-1.275 0-.75-.525-1.3t-1.275-.55q-.8 0-1.325.55-.525.55-.525 1.3t.55 1.275q.55.525 1.3.525Zm-1.85-6.1h3.65V19.4H22.4Z" />
|
||||
<path fill="currentColor" d="M.7 43.05 24 2.85l23.3 40.2Zm23.55-6.25q.75 0 1.275-.525.525-.525.525-1.275 0-.75-.525-1.3t-1.275-.55q-.8 0-1.325.55-.525.55-.525 1.3t.55 1.275q.55.525 1.3.525Zm-1.85-6.1h3.65V19.4H22.4Z" />
|
||||
</svg>
|
||||
)}
|
||||
</Tooltip>
|
||||
@ -192,7 +209,7 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
||||
{(!channel.isGuildVoice() && !channel.isGuildStageVoice()) && (
|
||||
<Text variant="text-lg/normal">
|
||||
You can not see the {channel.isForumChannel() ? "posts" : "messages"} of this channel.
|
||||
{channel.isForumChannel() && topic && topic.length > 0 && "However you may see its guidelines:"}
|
||||
{channel.isForumChannel() && topic && topic.length > 0 && " However you may see its guidelines:"}
|
||||
</Text >
|
||||
)}
|
||||
|
||||
@ -268,8 +285,49 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
||||
</div>
|
||||
}
|
||||
<div className="shc-lock-screen-allowed-users-and-roles-container">
|
||||
<Text variant="text-lg/bold">Allowed users and roles:</Text>
|
||||
<ChannelBeginHeader channel={channel} />
|
||||
<div className="shc-lock-screen-allowed-users-and-roles-container-title">
|
||||
{Settings.plugins.PermissionsViewer.enabled && (
|
||||
<Tooltip text="Permission Details">
|
||||
{({ onMouseLeave, onMouseEnter }) => (
|
||||
<button
|
||||
onMouseLeave={onMouseLeave}
|
||||
onMouseEnter={onMouseEnter}
|
||||
className="shc-lock-screen-allowed-users-and-roles-container-permdetails-btn"
|
||||
onClick={() => openRolesAndUsersPermissionsModal(permissions, GuildStore.getGuild(channel.guild_id), channel.name)}
|
||||
>
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path fill="currentColor" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</Tooltip>
|
||||
)}
|
||||
<Text variant="text-lg/bold">Allowed users and roles:</Text>
|
||||
<Tooltip text={viewAllowedUsersAndRoles ? "Hide Allowed Users and Roles" : "View Allowed Users and Roles"}>
|
||||
{({ onMouseLeave, onMouseEnter }) => (
|
||||
<button
|
||||
onMouseLeave={onMouseLeave}
|
||||
onMouseEnter={onMouseEnter}
|
||||
className="shc-lock-screen-allowed-users-and-roles-container-toggle-btn"
|
||||
onClick={() => setViewAllowedUsersAndRoles(v => !v)}
|
||||
>
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
transform={viewAllowedUsersAndRoles ? "scale(1 -1)" : "scale(1 1)"}
|
||||
>
|
||||
<path fill="currentColor" d="M16.59 8.59003L12 13.17L7.41 8.59003L6 10L12 16L18 10L16.59 8.59003Z" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</Tooltip>
|
||||
</div>
|
||||
{viewAllowedUsersAndRoles && <ChannelBeginHeader channel={channel} />}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -39,7 +39,7 @@ enum ShowMode {
|
||||
HiddenIconWithMutedStyle
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
export const settings = definePluginSettings({
|
||||
hideUnreads: {
|
||||
description: "Hide Unreads",
|
||||
type: OptionType.BOOLEAN,
|
||||
@ -54,6 +54,11 @@ const settings = definePluginSettings({
|
||||
{ label: "Muted style with hidden eye icon on the right", value: ShowMode.HiddenIconWithMutedStyle },
|
||||
],
|
||||
restartNeeded: true
|
||||
},
|
||||
defaultAllowedUsersAndRolesDropdownState: {
|
||||
description: "Whether the allowed users and roles dropdown on hidden channels should be open by default",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true
|
||||
}
|
||||
});
|
||||
|
||||
@ -102,13 +107,13 @@ export default definePlugin({
|
||||
},
|
||||
{
|
||||
// Prevent Discord from trying to connect to hidden channels
|
||||
match: /(?=\|\|\i\.default\.selectVoiceChannel\((\i)\.id\))/,
|
||||
replace: (_, channel) => `||$self.isHiddenChannel(${channel})`
|
||||
match: /if\(!\i&&!\i(?=.{0,50}?selectVoiceChannel\((\i)\.id\))/,
|
||||
replace: (m, channel) => `${m}&&!$self.isHiddenChannel(${channel})`
|
||||
},
|
||||
{
|
||||
// Make Discord show inside the channel if clicking on a hidden or locked channel
|
||||
match: /(?<=\|\|\i\.default\.selectVoiceChannel\((\i)\.id\);!__OVERLAY__&&\()/,
|
||||
replace: (_, channel) => `$self.isHiddenChannel(${channel},true)||`
|
||||
match: /!__OVERLAY__&&\((?<=selectVoiceChannel\((\i)\.id\).+?)/,
|
||||
replace: (m, channel) => `${m}$self.isHiddenChannel(${channel},true)||`
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -190,7 +195,7 @@ export default definePlugin({
|
||||
replace: (_, pushNotificationButtonExpression, channel) => `if($self.isHiddenChannel(${channel})){${pushNotificationButtonExpression}break;}`
|
||||
},
|
||||
{
|
||||
match: /(?<=renderHeaderToolbar=function.+?case \i\.\i\.GUILD_FORUM:if\(!\i\){)(?=.+?;(.+?{channel:(\i)},"notifications"\)\)))/,
|
||||
match: /(?<=renderHeaderToolbar=function.+?case \i\.\i\.GUILD_FORUM:.+?if\(!\i\){)(?=.+?;(.+?{channel:(\i)},"notifications"\)\)))/,
|
||||
replace: (_, pushNotificationButtonExpression, channel) => `if($self.isHiddenChannel(${channel})){${pushNotificationButtonExpression};break;}`
|
||||
},
|
||||
{
|
||||
|
@ -33,9 +33,8 @@
|
||||
margin: inherit;
|
||||
}
|
||||
|
||||
.shc-lock-screen-heading-nsfw-icon > path {
|
||||
fill: var(--text-normal);
|
||||
fill-rule: evenodd;
|
||||
.shc-lock-screen-heading-nsfw-icon {
|
||||
color: var(--text-normal);
|
||||
}
|
||||
|
||||
.shc-lock-screen-topic-container {
|
||||
@ -99,6 +98,36 @@
|
||||
max-width: 70vw;
|
||||
}
|
||||
|
||||
.shc-lock-screen-allowed-users-and-roles-container-title {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.shc-lock-screen-allowed-users-and-roles-container-toggle-btn {
|
||||
all: unset;
|
||||
margin-left: 5px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.shc-lock-screen-allowed-users-and-roles-container-toggle-btn > svg {
|
||||
color: var(--text-normal);
|
||||
}
|
||||
|
||||
.shc-lock-screen-allowed-users-and-roles-container-permdetails-btn {
|
||||
all: unset;
|
||||
margin-right: 5px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.shc-lock-screen-allowed-users-and-roles-container-permdetails-btn > svg {
|
||||
color: var(--text-normal);
|
||||
}
|
||||
|
||||
.shc-lock-screen-allowed-users-and-roles-container > [class^="members"] {
|
||||
margin-left: 10px;
|
||||
flex-wrap: wrap;
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
import { DataStore } from "@api/index";
|
||||
import { Devs, SUPPORT_CHANNEL_ID } from "@utils/constants";
|
||||
import { isPluginDev } from "@utils/misc";
|
||||
import { makeCodeblock } from "@utils/text";
|
||||
import definePlugin from "@utils/types";
|
||||
import { isOutdated } from "@utils/updater";
|
||||
@ -30,6 +31,12 @@ import settings from "./settings";
|
||||
|
||||
const REMEMBER_DISMISS_KEY = "Vencord-SupportHelper-Dismiss";
|
||||
|
||||
const AllowedChannelIds = [
|
||||
SUPPORT_CHANNEL_ID,
|
||||
"1024286218801926184", // Vencord > #bot-spam
|
||||
"1033680203433660458", // Vencord > #v
|
||||
];
|
||||
|
||||
export default definePlugin({
|
||||
name: "SupportHelper",
|
||||
required: true,
|
||||
@ -40,7 +47,7 @@ export default definePlugin({
|
||||
commands: [{
|
||||
name: "vencord-debug",
|
||||
description: "Send Vencord Debug info",
|
||||
predicate: ctx => ctx.channel.id === SUPPORT_CHANNEL_ID,
|
||||
predicate: ctx => AllowedChannelIds.includes(ctx.channel.id),
|
||||
execute() {
|
||||
const { RELEASE_CHANNEL } = window.GLOBAL_ENV;
|
||||
|
||||
@ -51,21 +58,26 @@ export default definePlugin({
|
||||
return `Web (${navigator.userAgent})`;
|
||||
})();
|
||||
|
||||
const isApiPlugin = (plugin: string) => plugin.endsWith("API") || plugins[plugin].required;
|
||||
|
||||
const enabledPlugins = Object.keys(plugins).filter(p => Vencord.Plugins.isPluginEnabled(p) && !isApiPlugin(p));
|
||||
const enabledApiPlugins = Object.keys(plugins).filter(p => Vencord.Plugins.isPluginEnabled(p) && isApiPlugin(p));
|
||||
|
||||
const debugInfo = `
|
||||
**Vencord Debug Info**
|
||||
>>> Discord Branch: ${RELEASE_CHANNEL}
|
||||
Client: ${client}
|
||||
Platform: ${window.navigator.platform}
|
||||
Vencord: ${gitHash}${settings.additionalInfo}
|
||||
Outdated: ${isOutdated}
|
||||
OpenAsar: ${"openasar" in window}
|
||||
|
||||
> Discord Branch: ${RELEASE_CHANNEL}
|
||||
> Client: ${client}
|
||||
> Platform: ${window.navigator.platform}
|
||||
> Vencord Version: ${gitHash}${settings.additionalInfo}
|
||||
> OpenAsar: ${"openasar" in window}
|
||||
> Outdated: ${isOutdated}
|
||||
> Enabled Plugins:
|
||||
${makeCodeblock(Object.keys(plugins).filter(Vencord.Plugins.isPluginEnabled).join(", "))}
|
||||
Enabled Plugins (${enabledPlugins.length + enabledApiPlugins.length}):
|
||||
${makeCodeblock(enabledPlugins.join(", ") + "\n\n" + enabledApiPlugins.join(", "))}
|
||||
`;
|
||||
|
||||
return {
|
||||
content: debugInfo.trim()
|
||||
content: debugInfo.trim().replaceAll("```\n", "```")
|
||||
};
|
||||
}
|
||||
}],
|
||||
@ -74,8 +86,7 @@ ${makeCodeblock(Object.keys(plugins).filter(Vencord.Plugins.isPluginEnabled).joi
|
||||
async CHANNEL_SELECT({ channelId }) {
|
||||
if (channelId !== SUPPORT_CHANNEL_ID) return;
|
||||
|
||||
const myId = BigInt(UserStore.getCurrentUser().id);
|
||||
if (Object.values(Devs).some(d => d.id === myId)) return;
|
||||
if (isPluginDev(UserStore.getCurrentUser().id)) return;
|
||||
|
||||
if (isOutdated && gitHash !== await DataStore.get(REMEMBER_DISMISS_KEY)) {
|
||||
const rememberDismiss = () => DataStore.set(REMEMBER_DISMISS_KEY, gitHash);
|
||||
|
@ -59,7 +59,7 @@ export async function translate(kind: "received" | "sent", text: string): Promis
|
||||
const res = await fetch(url);
|
||||
if (!res.ok)
|
||||
throw new Error(
|
||||
`Failed to translate "${text}" (${sourceLang} -> ${targetLang}`
|
||||
`Failed to translate "${text}" (${sourceLang} -> ${targetLang})`
|
||||
+ `\n${res.status} ${res.statusText}`
|
||||
);
|
||||
|
||||
|
@ -89,7 +89,7 @@ function TypingIndicator({ channelId }: { channelId: string; }) {
|
||||
<Tooltip text={tooltipText!}>
|
||||
{({ onMouseLeave, onMouseEnter }) => (
|
||||
<div
|
||||
style={{ marginLeft: 6, zIndex: 0, cursor: "pointer" }}
|
||||
style={{ marginLeft: 6, height: 16, display: "flex", alignItems: "center", zIndex: 0, cursor: "pointer" }}
|
||||
onMouseLeave={onMouseLeave}
|
||||
onMouseEnter={onMouseEnter}
|
||||
>
|
||||
|
@ -89,7 +89,11 @@ const TypingUser = ErrorBoundary.wrap(function ({ user, guildId }: Props) {
|
||||
src={user.getAvatarURL(guildId, 128)} />
|
||||
</div>
|
||||
)}
|
||||
{GuildMemberStore.getNick(guildId!, user.id) || !guildId && RelationshipStore.getNickname(user.id) || user.username}
|
||||
{GuildMemberStore.getNick(guildId!, user.id)
|
||||
|| (!guildId && RelationshipStore.getNickname(user.id))
|
||||
|| (user as any).globalName
|
||||
|| user.username
|
||||
}
|
||||
</strong>
|
||||
);
|
||||
}, { noop: true });
|
||||
|
@ -41,37 +41,48 @@ export default definePlugin({
|
||||
],
|
||||
execute: async (args, ctx) => {
|
||||
try {
|
||||
const { list: [definition] } = await (await fetch(`https://api.urbandictionary.com/v0/define?term=${args[0].value}`)).json();
|
||||
const query = encodeURIComponent(args[0].value);
|
||||
const { list: [definition] } = await (await fetch(`https://api.urbandictionary.com/v0/define?term=${query}`)).json();
|
||||
|
||||
if (!definition)
|
||||
return void sendBotMessage(ctx.channel.id, { content: "No results found." });
|
||||
|
||||
const linkify = text => text.replace(/\[(.+?)\]/g, (_, word) => `[${word}](https://www.urbandictionary.com/define.php?term=${encodeURIComponent(word)})`);
|
||||
const linkify = (text: string) => text
|
||||
.replaceAll("\r\n", "\n")
|
||||
.replace(/([*>_`~\\])/gsi, "\\$1")
|
||||
.replace(/\[(.+?)\]/g, (_, word) => `[${word}](https://www.urbandictionary.com/define.php?term=${encodeURIComponent(word)} "Define '${word}' on Urban Dictionary")`)
|
||||
.trim();
|
||||
|
||||
return void sendBotMessage(ctx.channel.id, {
|
||||
embeds: [
|
||||
{
|
||||
type: "rich",
|
||||
author: {
|
||||
name: `Definition of ${definition.word}`,
|
||||
url: definition.permalink
|
||||
name: `Uploaded by "${definition.author}"`,
|
||||
url: `https://www.urbandictionary.com/author.php?author=${encodeURIComponent(definition.author)}`,
|
||||
},
|
||||
title: definition.word,
|
||||
url: `https://www.urbandictionary.com/define.php?term=${encodeURIComponent(definition.word)}`,
|
||||
description: linkify(definition.definition),
|
||||
fields: [
|
||||
{
|
||||
name: "Example",
|
||||
value: linkify(definition.example)
|
||||
}
|
||||
value: linkify(definition.example),
|
||||
},
|
||||
{
|
||||
name: "Want more definitions?",
|
||||
value: `Check out [more definitions](https://www.urbandictionary.com/define.php?term=${query} "Define "${args[0].value}" on Urban Dictionary") on Urban Dictionary.`,
|
||||
},
|
||||
],
|
||||
color: 0xFF9900,
|
||||
footer: { text: `👍 ${definition.thumbs_up.toString()} | 👎 ${definition.thumbs_down.toString()} | Uploaded by ${definition.author}`, icon_url: "https://www.urbandictionary.com/favicon.ico" },
|
||||
timestamp: new Date(definition.written_on).toISOString()
|
||||
}
|
||||
] as any
|
||||
footer: { text: `👍 ${definition.thumbs_up.toString()} | 👎 ${definition.thumbs_down.toString()}`, icon_url: "https://www.urbandictionary.com/favicon.ico" },
|
||||
timestamp: new Date(definition.written_on).toISOString(),
|
||||
},
|
||||
] as any,
|
||||
});
|
||||
} catch (error) {
|
||||
return void sendBotMessage(ctx.channel.id, {
|
||||
content: `Something went wrong: \`${error}\``
|
||||
sendBotMessage(ctx.channel.id, {
|
||||
content: `Something went wrong: \`${error}\``,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,10 @@
|
||||
*/
|
||||
|
||||
import { findOption, RequiredMessageOption } from "@api/Commands";
|
||||
import { addPreEditListener, addPreSendListener, MessageObject, removePreEditListener, removePreSendListener } from "@api/MessageEvents";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
const endings = [
|
||||
"rawr x3",
|
||||
@ -65,6 +67,15 @@ const replacements = [
|
||||
["meow", "nya~"],
|
||||
];
|
||||
|
||||
const settings = definePluginSettings({
|
||||
uwuEveryMessage: {
|
||||
description: "Make every single message uwuified",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false,
|
||||
restartNeeded: false
|
||||
}
|
||||
});
|
||||
|
||||
function selectRandomElement(arr) {
|
||||
// generate a random index based on the length of the array
|
||||
const randomIndex = Math.floor(Math.random() * arr.length);
|
||||
@ -94,8 +105,9 @@ function uwuify(message: string): string {
|
||||
export default definePlugin({
|
||||
name: "UwUifier",
|
||||
description: "Simply uwuify commands",
|
||||
authors: [Devs.echo, Devs.skyevg],
|
||||
dependencies: ["CommandsAPI"],
|
||||
authors: [Devs.echo, Devs.skyevg, Devs.PandaNinjas],
|
||||
dependencies: ["CommandsAPI", "MessageEventsAPI"],
|
||||
settings,
|
||||
|
||||
commands: [
|
||||
{
|
||||
@ -108,4 +120,23 @@ export default definePlugin({
|
||||
}),
|
||||
},
|
||||
],
|
||||
|
||||
onSend(msg: MessageObject) {
|
||||
// Only run when it's enabled
|
||||
if (settings.store.uwuEveryMessage) {
|
||||
msg.content = uwuify(msg.content);
|
||||
}
|
||||
},
|
||||
|
||||
start() {
|
||||
this.preSend = addPreSendListener((_, msg) => this.onSend(msg));
|
||||
this.preEdit = addPreEditListener((_cid, _mid, msg) =>
|
||||
this.onSend(msg)
|
||||
);
|
||||
},
|
||||
|
||||
stop() {
|
||||
removePreSendListener(this.preSend);
|
||||
removePreEditListener(this.preEdit);
|
||||
},
|
||||
});
|
||||
|
@ -59,17 +59,20 @@ function speak(text: string, settings: any = Settings.plugins.VcNarrator) {
|
||||
speechSynthesis.speak(speech);
|
||||
}
|
||||
|
||||
function clean(str: string, fallback: string) {
|
||||
function clean(str: string) {
|
||||
const replacer = Settings.plugins.VcNarrator.latinOnly
|
||||
? /[^\p{Script=Latin}\p{Number}\p{Punctuation}\s]/gu
|
||||
: /[^\p{Letter}\p{Number}\p{Punctuation}\s]/gu;
|
||||
|
||||
return str.normalize("NFKC")
|
||||
.replace(/[^\w ]/g, "")
|
||||
.trim()
|
||||
|| fallback;
|
||||
.replace(replacer, "")
|
||||
.trim();
|
||||
}
|
||||
|
||||
function formatText(str: string, user: string, channel: string) {
|
||||
return str
|
||||
.replaceAll("{{USER}}", clean(user, user ? "Someone" : ""))
|
||||
.replaceAll("{{CHANNEL}}", clean(channel, "channel"));
|
||||
.replaceAll("{{USER}}", clean(user) || user ? "Someone" : "")
|
||||
.replaceAll("{{CHANNEL}}", clean(channel) || "channel");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -165,7 +168,7 @@ export default definePlugin({
|
||||
if (!type) continue;
|
||||
|
||||
const template = Settings.plugins.VcNarrator[type + "Message"];
|
||||
const user = isMe ? "" : UserStore.getUser(userId).username;
|
||||
const user = isMe && !Settings.plugins.VcNarrator.sayOwnName ? "" : UserStore.getUser(userId).username;
|
||||
const channel = ChannelStore.getChannel(id).name;
|
||||
|
||||
speak(formatText(template, user, channel));
|
||||
@ -230,6 +233,16 @@ export default definePlugin({
|
||||
markers: [0.1, 0.5, 1, 2, 5, 10],
|
||||
stickToMarkers: false
|
||||
},
|
||||
sayOwnName: {
|
||||
description: "Say own name",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
latinOnly: {
|
||||
description: "Strip non latin characters from names before saying them",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
},
|
||||
joinMessage: {
|
||||
type: OptionType.STRING,
|
||||
description: "Join Message",
|
||||
|
@ -29,7 +29,18 @@ export const REACT_GLOBAL = "Vencord.Webpack.Common.React";
|
||||
export const VENCORD_USER_AGENT = `Vencord/${gitHash}${gitRemote ? ` (https://github.com/${gitRemote})` : ""}`;
|
||||
export const SUPPORT_CHANNEL_ID = "1026515880080842772";
|
||||
|
||||
// Add yourself here if you made a plugin
|
||||
export interface Dev {
|
||||
name: string;
|
||||
id: bigint;
|
||||
badge?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you made a plugin or substantial contribution, add yourself here.
|
||||
* This object is used for the plugin author list, as well as to add a contributor badge to your profile.
|
||||
* If you wish to stay fully anonymous, feel free to set ID to 0n.
|
||||
* If you are fine with attribution but don't want the badge, add badge: false
|
||||
*/
|
||||
export const Devs = /* #__PURE__*/ Object.freeze({
|
||||
Ven: {
|
||||
name: "Vendicated",
|
||||
@ -201,7 +212,8 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||
},
|
||||
nick: {
|
||||
name: "nick",
|
||||
id: 347884694408265729n
|
||||
id: 347884694408265729n,
|
||||
badge: false
|
||||
},
|
||||
whqwert: {
|
||||
name: "whqwert",
|
||||
@ -287,6 +299,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||
name: "carince",
|
||||
id: 818323528755314698n
|
||||
},
|
||||
PandaNinjas: {
|
||||
name: "PandaNinjas",
|
||||
id: 455128749071925248n
|
||||
},
|
||||
CatNoir: {
|
||||
name: "CatNoir",
|
||||
id: 260371016348336128n
|
||||
@ -295,4 +311,17 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||
name: "outfoxxed",
|
||||
id: 837425748435796060n
|
||||
},
|
||||
});
|
||||
UwUDev: {
|
||||
name: "UwU",
|
||||
id: 691413039156690994n,
|
||||
},
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
// iife so #__PURE__ works correctly
|
||||
export const DevsById = /* #__PURE__*/ (() =>
|
||||
Object.freeze(Object.fromEntries(
|
||||
Object.entries(Devs)
|
||||
.filter(d => d[1].id !== 0n)
|
||||
.map(([_, v]) => [v.id, v] as const)
|
||||
))
|
||||
)() as Record<string, Dev>;
|
||||
|
@ -16,11 +16,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { findLazy } from "@webpack";
|
||||
import { MessageObject } from "@api/MessageEvents";
|
||||
import { findByPropsLazy, findLazy } from "@webpack";
|
||||
import { ChannelStore, ComponentDispatch, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { Guild } from "discord-types/general";
|
||||
import { Guild, Message } from "discord-types/general";
|
||||
|
||||
const PreloadedUserSettings = findLazy(m => m.ProtoClass?.typeName.endsWith("PreloadedUserSettings"));
|
||||
const MessageActions = findByPropsLazy("editMessage", "sendMessage");
|
||||
|
||||
export function getCurrentChannel() {
|
||||
return ChannelStore.getChannel(SelectedChannelStore.getChannelId());
|
||||
@ -49,3 +51,29 @@ export function insertTextIntoChatInputBox(text: string) {
|
||||
plainText: text
|
||||
});
|
||||
}
|
||||
|
||||
interface MessageExtra {
|
||||
messageReference: Message["messageReference"];
|
||||
allowedMentions: {
|
||||
parse: string[];
|
||||
replied_user: boolean;
|
||||
};
|
||||
stickerIds: string[];
|
||||
}
|
||||
|
||||
export function sendMessage(
|
||||
channelId: string,
|
||||
data: Partial<MessageObject>,
|
||||
waitForChannelReady?: boolean,
|
||||
extra?: Partial<MessageExtra>
|
||||
) {
|
||||
const messageData = {
|
||||
content: "",
|
||||
invalidEmojis: [],
|
||||
tts: false,
|
||||
validNonShortcutEmojis: [],
|
||||
...data
|
||||
};
|
||||
|
||||
return MessageActions.sendMessage(channelId, messageData, waitForChannelReady, extra);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
import { Clipboard, Toasts } from "@webpack/common";
|
||||
|
||||
import { DevsById } from "./constants";
|
||||
|
||||
/**
|
||||
* Recursively merges defaults into an object and returns the same object
|
||||
* @param obj Object
|
||||
@ -100,3 +102,5 @@ export function identity<T>(value: T): T {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#mobile_tablet_or_desktop
|
||||
// "In summary, we recommend looking for the string Mobi anywhere in the User Agent to detect a mobile device."
|
||||
export const isMobile = navigator.userAgent.includes("Mobi");
|
||||
|
||||
export const isPluginDev = (id: string) => Object.hasOwn(DevsById, id);
|
||||
|
@ -67,6 +67,7 @@ interface AwaiterOpts<T> {
|
||||
fallbackValue: T;
|
||||
deps?: unknown[];
|
||||
onError?(e: any): void;
|
||||
onSuccess?(value: T): void;
|
||||
}
|
||||
/**
|
||||
* Await a promise
|
||||
@ -94,8 +95,16 @@ export function useAwaiter<T>(factory: () => Promise<T>, providedOpts?: AwaiterO
|
||||
if (!state.pending) setState({ ...state, pending: true });
|
||||
|
||||
factory()
|
||||
.then(value => isAlive && setState({ value, error: null, pending: false }))
|
||||
.catch(error => isAlive && (setState({ value: null, error, pending: false }), opts.onError?.(error)));
|
||||
.then(value => {
|
||||
if (!isAlive) return;
|
||||
setState({ value, error: null, pending: false });
|
||||
opts.onSuccess?.(value);
|
||||
})
|
||||
.catch(error => {
|
||||
if (!isAlive) return;
|
||||
setState({ value: null, error, pending: false });
|
||||
opts.onError?.(error);
|
||||
});
|
||||
|
||||
return () => void (isAlive = false);
|
||||
}, opts.deps);
|
||||
|
@ -277,6 +277,8 @@ export interface DefinedSettings<D extends SettingsDefinition = SettingsDefiniti
|
||||
* will be an empty string until plugin is initialized
|
||||
*/
|
||||
pluginName: string;
|
||||
|
||||
withPrivateSettings<T>(): this & { store: T; };
|
||||
}
|
||||
|
||||
export type PartialExcept<T, R extends keyof T> = Partial<T> & Required<Pick<T, R>>;
|
||||
|
@ -43,6 +43,7 @@ export let ButtonLooks: t.ButtonLooks;
|
||||
export let Popout: t.Popout;
|
||||
export let Dialog: t.Dialog;
|
||||
export let TabBar: any;
|
||||
export let Paginator: t.Paginator;
|
||||
// token lagger real
|
||||
/** css colour resolver stuff, no clue what exactly this does, just copied usage from Discord */
|
||||
export let useToken: t.useToken;
|
||||
@ -53,6 +54,6 @@ export const Flex = waitForComponent<t.Flex>("Flex", ["Justify", "Align", "Wrap"
|
||||
export const ButtonWrapperClasses = findByPropsLazy("buttonWrapper", "buttonContent") as Record<string, string>;
|
||||
|
||||
waitFor("FormItem", m => {
|
||||
({ useToken, Card, Button, FormSwitch: Switch, Tooltip, TextInput, TextArea, Text, Select, SearchableSelect, Slider, ButtonLooks, TabBar, Popout, Dialog } = m);
|
||||
({ useToken, Card, Button, FormSwitch: Switch, Tooltip, TextInput, TextArea, Text, Select, SearchableSelect, Slider, ButtonLooks, TabBar, Popout, Dialog, Paginator } = m);
|
||||
Forms = m;
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ import * as t from "./types/stores";
|
||||
|
||||
export const Flux: t.Flux = findByPropsLazy("connectStores");
|
||||
|
||||
type GenericStore = t.FluxStore & Record<string, any>;
|
||||
export type GenericStore = t.FluxStore & Record<string, any>;
|
||||
|
||||
export let MessageStore: Omit<Stores.MessageStore, "getMessages"> & {
|
||||
getMessages(chanId: string): any;
|
||||
@ -37,6 +37,7 @@ export let PermissionStore: GenericStore;
|
||||
export let GuildChannelStore: GenericStore;
|
||||
export let ReadStateStore: GenericStore;
|
||||
export let PresenceStore: GenericStore;
|
||||
export let PoggerModeSettingsStore: GenericStore;
|
||||
|
||||
export let GuildStore: Stores.GuildStore & t.FluxStore;
|
||||
export let UserStore: Stores.UserStore & t.FluxStore;
|
||||
@ -49,6 +50,7 @@ export let RelationshipStore: Stores.RelationshipStore & t.FluxStore & {
|
||||
getSince(userId: string): string;
|
||||
};
|
||||
|
||||
export let EmojiStore: t.EmojiStore;
|
||||
export let WindowStore: t.WindowStore;
|
||||
|
||||
export const MaskedLinkStore = mapMangledModuleLazy('"MaskedLinkStore"', {
|
||||
@ -87,3 +89,4 @@ waitForStore("ReadStateStore", m => ReadStateStore = m);
|
||||
waitForStore("GuildChannelStore", m => GuildChannelStore = m);
|
||||
waitForStore("MessageStore", m => MessageStore = m);
|
||||
waitForStore("WindowStore", m => WindowStore = m);
|
||||
waitForStore("EmojiStore", m => EmojiStore = m);
|
||||
|
10
src/webpack/common/types/components.d.ts
vendored
10
src/webpack/common/types/components.d.ts
vendored
@ -387,3 +387,13 @@ export type useToken = (color: {
|
||||
css: string;
|
||||
resolve: Resolve;
|
||||
}) => ReturnType<Resolve>;
|
||||
|
||||
export type Paginator = ComponentType<{
|
||||
currentPage: number;
|
||||
maxVisiblePages: number;
|
||||
pageSize: number;
|
||||
totalCount: number;
|
||||
|
||||
onPageChange?(page: number): void;
|
||||
hideMaxPage?: boolean;
|
||||
}>;
|
||||
|
101
src/webpack/common/types/stores.d.ts
vendored
101
src/webpack/common/types/stores.d.ts
vendored
@ -16,6 +16,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Channel } from "discord-types/general";
|
||||
|
||||
import { FluxDispatcher, FluxEvents } from "./utils";
|
||||
|
||||
export class FluxStore {
|
||||
@ -38,3 +40,102 @@ export class WindowStore extends FluxStore {
|
||||
isFocused(): boolean;
|
||||
windowSize(): Record<"width" | "height", number>;
|
||||
}
|
||||
|
||||
type Emoji = CustomEmoji | UnicodeEmoji;
|
||||
export interface CustomEmoji {
|
||||
allNamesString: string;
|
||||
animated: boolean;
|
||||
available: boolean;
|
||||
guildId: string;
|
||||
id: string;
|
||||
managed: boolean;
|
||||
name: string;
|
||||
originalName?: string;
|
||||
require_colons: boolean;
|
||||
roles: string[];
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface UnicodeEmoji {
|
||||
diversityChildren: Record<any, any>;
|
||||
emojiObject: {
|
||||
names: string[];
|
||||
surrogates: string;
|
||||
unicodeVersion: number;
|
||||
};
|
||||
index: number;
|
||||
surrogates: string;
|
||||
uniqueName: string;
|
||||
useSpriteSheet: boolean;
|
||||
get allNamesString(): string;
|
||||
get animated(): boolean;
|
||||
get defaultDiversityChild(): any;
|
||||
get hasDiversity(): boolean | undefined;
|
||||
get hasDiversityParent(): boolean | undefined;
|
||||
get hasMultiDiversity(): boolean | undefined;
|
||||
get hasMultiDiversityParent(): boolean | undefined;
|
||||
get managed(): boolean;
|
||||
get name(): string;
|
||||
get names(): string[];
|
||||
get optionallyDiverseSequence(): string | undefined;
|
||||
get unicodeVersion(): number;
|
||||
get url(): string;
|
||||
}
|
||||
|
||||
export class EmojiStore extends FluxStore {
|
||||
getCustomEmojiById(id?: string | null): CustomEmoji;
|
||||
getUsableCustomEmojiById(id?: string | null): CustomEmoji;
|
||||
getGuilds(): Record<string, {
|
||||
id: string;
|
||||
_emojiMap: Record<string, CustomEmoji>;
|
||||
_emojis: CustomEmoji[];
|
||||
get emojis(): CustomEmoji[];
|
||||
get rawEmojis(): CustomEmoji[];
|
||||
_usableEmojis: CustomEmoji[];
|
||||
get usableEmojis(): CustomEmoji[];
|
||||
_emoticons: any[];
|
||||
get emoticons(): any[];
|
||||
}>;
|
||||
getGuildEmoji(guildId?: string | null): CustomEmoji[];
|
||||
getNewlyAddedEmoji(guildId?: string | null): CustomEmoji[];
|
||||
getTopEmoji(guildId?: string | null): CustomEmoji[];
|
||||
getTopEmojisMetadata(guildId?: string | null): {
|
||||
emojiIds: string[];
|
||||
topEmojisTTL: number;
|
||||
};
|
||||
hasPendingUsage(): boolean;
|
||||
hasUsableEmojiInAnyGuild(): boolean;
|
||||
searchWithoutFetchingLatest(data: any): any;
|
||||
getSearchResultsOrder(...args: any[]): any;
|
||||
getState(): {
|
||||
pendingUsages: { key: string, timestamp: number; }[];
|
||||
};
|
||||
searchWithoutFetchingLatest(data: {
|
||||
channel: Channel,
|
||||
query: string;
|
||||
count?: number;
|
||||
intention: number;
|
||||
includeExternalGuilds?: boolean;
|
||||
matchComparator?(name: string): boolean;
|
||||
}): Record<"locked" | "unlocked", Emoji[]>;
|
||||
|
||||
getDisambiguatedEmojiContext(): {
|
||||
backfillTopEmojis: Record<any, any>;
|
||||
customEmojis: Record<string, CustomEmoji>;
|
||||
emojisById: Record<string, CustomEmoji>;
|
||||
emojisByName: Record<string, CustomEmoji>;
|
||||
emoticonRegex: RegExp | null;
|
||||
emoticonsByName: Record<string, any>;
|
||||
escapedEmoticonNames: string;
|
||||
favoriteNamesAndIds?: any;
|
||||
favorites?: any;
|
||||
frequentlyUsed?: any;
|
||||
groupedCustomEmojis: Record<string, CustomEmoji[]>;
|
||||
guildId?: string;
|
||||
isFavoriteEmojiWithoutFetchingLatest(e: Emoji): boolean;
|
||||
newlyAddedEmoji: Record<string, CustomEmoji[]>;
|
||||
topEmojis?: any;
|
||||
unicodeAliases: Record<string, string>;
|
||||
get favoriteEmojisWithoutFetchingLatest(): Emoji[];
|
||||
};
|
||||
}
|
||||
|
@ -28,21 +28,27 @@ let webpackChunk: any[];
|
||||
|
||||
const logger = new Logger("WebpackInterceptor", "#8caaee");
|
||||
|
||||
Object.defineProperty(window, WEBPACK_CHUNK, {
|
||||
get: () => webpackChunk,
|
||||
set: v => {
|
||||
if (v?.push !== Array.prototype.push) {
|
||||
logger.info(`Patching ${WEBPACK_CHUNK}.push`);
|
||||
_initWebpack(v);
|
||||
patchPush();
|
||||
// @ts-ignore
|
||||
delete window[WEBPACK_CHUNK];
|
||||
window[WEBPACK_CHUNK] = v;
|
||||
}
|
||||
webpackChunk = v;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
if (window[WEBPACK_CHUNK]) {
|
||||
logger.info(`Patching ${WEBPACK_CHUNK}.push (was already existant, likely from cache!)`);
|
||||
_initWebpack(window[WEBPACK_CHUNK]);
|
||||
patchPush();
|
||||
} else {
|
||||
Object.defineProperty(window, WEBPACK_CHUNK, {
|
||||
get: () => webpackChunk,
|
||||
set: v => {
|
||||
if (v?.push !== Array.prototype.push) {
|
||||
logger.info(`Patching ${WEBPACK_CHUNK}.push`);
|
||||
_initWebpack(v);
|
||||
patchPush();
|
||||
// @ts-ignore
|
||||
delete window[WEBPACK_CHUNK];
|
||||
window[WEBPACK_CHUNK] = v;
|
||||
}
|
||||
webpackChunk = v;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
|
||||
function patchPush() {
|
||||
function handlePush(chunk: any) {
|
||||
|
Reference in New Issue
Block a user