Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
60325c6aa5 | ||
|
c2a1c4cbf6 | ||
|
1d6b78f6c6 | ||
|
341151a718 | ||
|
f6fd7cf37a | ||
|
d53476a32a | ||
|
fc943b7778 | ||
|
3f2bcd2cab | ||
|
235000cf41 | ||
|
263884cbd8 | ||
|
bb83c0b672 | ||
|
2815509c00 |
@ -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.
|
Mention of it does not imply any affiliation with or endorsement by Discord Inc.
|
||||||
|
|
||||||
<details>
|
<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.
|
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/>.
|
* 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) {
|
function parseHeaders(headers) {
|
||||||
if (!headers)
|
if (!headers)
|
||||||
return {};
|
return {};
|
||||||
@ -52,21 +38,6 @@ function parseHeaders(headers) {
|
|||||||
return result;
|
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) {
|
function blobTo(to, blob) {
|
||||||
if (to === "arrayBuffer" && blob.arrayBuffer) return blob.arrayBuffer();
|
if (to === "arrayBuffer" && blob.arrayBuffer) return blob.arrayBuffer();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -80,31 +51,25 @@ function blobTo(to, blob) {
|
|||||||
|
|
||||||
function GM_fetch(url, opt) {
|
function GM_fetch(url, opt) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
checkCors(url, opt?.method || "GET")
|
// https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest
|
||||||
.then(can => {
|
const options = opt || {};
|
||||||
if (can) {
|
options.url = url;
|
||||||
// https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest
|
options.data = options.body;
|
||||||
const options = opt || {};
|
options.responseType = "blob";
|
||||||
options.url = url;
|
options.onload = resp => {
|
||||||
options.data = options.body;
|
var blob = resp.response;
|
||||||
options.responseType = "blob";
|
resp.blob = () => Promise.resolve(blob);
|
||||||
options.onload = resp => {
|
resp.arrayBuffer = () => blobTo("arrayBuffer", blob);
|
||||||
var blob = resp.response;
|
resp.text = () => blobTo("text", blob);
|
||||||
resp.blob = () => Promise.resolve(blob);
|
resp.json = async () => JSON.parse(await blobTo("text", blob));
|
||||||
resp.arrayBuffer = () => blobTo("arrayBuffer", blob);
|
resp.headers = new Headers(parseHeaders(resp.responseHeaders));
|
||||||
resp.text = () => blobTo("text", blob);
|
resp.ok = resp.status >= 200 && resp.status < 300;
|
||||||
resp.json = async () => JSON.parse(await blobTo("text", blob));
|
resolve(resp);
|
||||||
resp.headers = new Headers(parseHeaders(resp.responseHeaders));
|
};
|
||||||
resolve(resp);
|
options.ontimeout = () => reject("fetch timeout");
|
||||||
};
|
options.onerror = () => reject("fetch error");
|
||||||
options.ontimeout = () => reject("fetch timeout");
|
options.onabort = () => reject("fetch abort");
|
||||||
options.onerror = () => reject("fetch error");
|
GM_xmlhttpRequest(options);
|
||||||
options.onabort = () => reject("fetch abort");
|
|
||||||
GM_xmlhttpRequest(options);
|
|
||||||
} else {
|
|
||||||
reject("CORS issue");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export const fetch = GM_fetch;
|
export const fetch = GM_fetch;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.2.3",
|
"version": "1.2.4",
|
||||||
"description": "The cutest Discord client mod",
|
"description": "The cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
@ -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
|
* @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)
|
* @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 navId The navId of the context menu being patched
|
||||||
* @param children The rendered context menu elements
|
* @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
|
* @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)
|
* @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");
|
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
|
* 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
|
* @param id The id of the child. If an array is specified, all ids will be tried
|
||||||
* @param children The context menu children
|
* @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) {
|
for (const child of children) {
|
||||||
if (child == null) continue;
|
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;
|
let nextChildren = child.props?.children;
|
||||||
if (nextChildren) {
|
if (nextChildren) {
|
||||||
@ -117,7 +120,7 @@ export function findGroupChildrenByChildId(id: string, children: Array<React.Rea
|
|||||||
interface ContextMenuProps {
|
interface ContextMenuProps {
|
||||||
contextMenuApiArguments?: Array<any>;
|
contextMenuApiArguments?: Array<any>;
|
||||||
navId: string;
|
navId: string;
|
||||||
children: Array<ReactElement>;
|
children: Array<ReactElement | null>;
|
||||||
"aria-label": string;
|
"aria-label": string;
|
||||||
onSelect: (() => void) | undefined;
|
onSelect: (() => void) | undefined;
|
||||||
onClose: (callback: (...args: Array<any>) => any) => void;
|
onClose: (callback: (...args: Array<any>) => any) => void;
|
||||||
|
@ -18,24 +18,15 @@
|
|||||||
|
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { MessageStore } from "@webpack/common";
|
import { MessageStore } from "@webpack/common";
|
||||||
|
import { CustomEmoji } from "@webpack/types";
|
||||||
import type { Channel, Message } from "discord-types/general";
|
import type { Channel, Message } from "discord-types/general";
|
||||||
import type { Promisable } from "type-fest";
|
import type { Promisable } from "type-fest";
|
||||||
|
|
||||||
const MessageEventsLogger = new Logger("MessageEvents", "#e5c890");
|
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 {
|
export interface MessageObject {
|
||||||
content: string,
|
content: string,
|
||||||
validNonShortcutEmojis: Emoji[];
|
validNonShortcutEmojis: CustomEmoji[];
|
||||||
invalidEmojis: any[];
|
invalidEmojis: any[];
|
||||||
tts: boolean;
|
tts: boolean;
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,11 @@ import { Margins } from "@utils/margins";
|
|||||||
import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
|
import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByCodeLazy, findStoreLazy } from "@webpack";
|
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";
|
import { Promisable } from "type-fest";
|
||||||
|
|
||||||
const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n;
|
const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n;
|
||||||
|
|
||||||
const GuildEmojiStore = findStoreLazy("EmojiStore");
|
|
||||||
const StickersStore = findStoreLazy("StickersStore");
|
const StickersStore = findStoreLazy("StickersStore");
|
||||||
const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS(");
|
const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS(");
|
||||||
|
|
||||||
@ -129,7 +128,7 @@ function getGuildCandidates(data: Data) {
|
|||||||
const { isAnimated } = data as Emoji;
|
const { isAnimated } = data as Emoji;
|
||||||
|
|
||||||
const emojiSlots = g.getMaxEmojiSlots();
|
const emojiSlots = g.getMaxEmojiSlots();
|
||||||
const { emojis } = GuildEmojiStore.getGuilds()[g.id];
|
const { emojis } = EmojiStore.getGuilds()[g.id];
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for (const emoji of emojis)
|
for (const emoji of emojis)
|
||||||
@ -194,7 +193,8 @@ function CloneModal({ data }: { data: Sticker | Emoji; }) {
|
|||||||
setName(v);
|
setName(v);
|
||||||
}}
|
}}
|
||||||
validate={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"
|
|| "Name must be between 2 and 32 characters and only contain alphanumeric characters"
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -24,7 +24,7 @@ import { getCurrentGuild } from "@utils/discord";
|
|||||||
import { proxyLazy } from "@utils/lazy";
|
import { proxyLazy } from "@utils/lazy";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
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 { Message } from "discord-types/general";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
@ -38,8 +38,6 @@ const StickerStore = findStoreLazy("StickersStore") as {
|
|||||||
getAllGuildStickers(): Map<string, Sticker[]>;
|
getAllGuildStickers(): Map<string, Sticker[]>;
|
||||||
getStickerById(id: string): Sticker | undefined;
|
getStickerById(id: string): Sticker | undefined;
|
||||||
};
|
};
|
||||||
const EmojiStore = findStoreLazy("EmojiStore");
|
|
||||||
|
|
||||||
|
|
||||||
function searchProtoClass(localName: string, parentProtoClass: any) {
|
function searchProtoClass(localName: string, parentProtoClass: any) {
|
||||||
if (!parentProtoClass) return;
|
if (!parentProtoClass) return;
|
||||||
@ -321,7 +319,7 @@ export default definePlugin({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleProtoChange(proto: any, user: any) {
|
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;
|
const premiumType: number = user?.premium_type ?? UserStore?.getCurrentUser()?.premiumType ?? 0;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
@ -22,7 +22,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getStegCloak } from "@utils/dependencies";
|
import { getStegCloak } from "@utils/dependencies";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
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 { Message } from "discord-types/general";
|
||||||
|
|
||||||
import { buildDecModal } from "./components/DecryptionModal";
|
import { buildDecModal } from "./components/DecryptionModal";
|
||||||
@ -123,7 +123,7 @@ const settings = definePluginSettings({
|
|||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "InvisibleChat",
|
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],
|
authors: [Devs.SammCheese],
|
||||||
dependencies: ["MessagePopoverAPI"],
|
dependencies: ["MessagePopoverAPI"],
|
||||||
patches: [
|
patches: [
|
||||||
@ -178,25 +178,13 @@ export default definePlugin({
|
|||||||
|
|
||||||
// Gets the Embed of a Link
|
// Gets the Embed of a Link
|
||||||
async getEmbed(url: URL): Promise<Object | {}> {
|
async getEmbed(url: URL): Promise<Object | {}> {
|
||||||
const controller = new AbortController();
|
const { body } = await RestAPI.post({
|
||||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
url: "/unfurler/embed-urls",
|
||||||
|
body: {
|
||||||
const options: RequestInit = {
|
urls: [url]
|
||||||
signal: controller.signal,
|
}
|
||||||
method: "POST",
|
});
|
||||||
headers: {
|
return await body.embeds[0];
|
||||||
"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();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async buildEmbed(message: any, revealed: string): Promise<void> {
|
async buildEmbed(message: any, revealed: string): Promise<void> {
|
||||||
|
@ -57,6 +57,8 @@ export const settings = definePluginSettings({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||||
|
if (type === MenuItemParentType.User && !GuildMemberStore.isMember(guildId, id!)) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="perm-viewer-permissions"
|
id="perm-viewer-permissions"
|
||||||
@ -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) => () => {
|
return (children, props) => () => {
|
||||||
if (!props) return children;
|
if (!props) return children;
|
||||||
|
|
||||||
const group = findGroupChildrenByChildId(childId, children);
|
const group = findGroupChildrenByChildId(childId, children);
|
||||||
|
|
||||||
if (group) {
|
const item = (() => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MenuItemParentType.User:
|
case MenuItemParentType.User:
|
||||||
group.push(MenuItem(props.guildId, props.user.id, type));
|
return MenuItem(props.guildId, props.user.id, type);
|
||||||
break;
|
|
||||||
case MenuItemParentType.Channel:
|
case MenuItemParentType.Channel:
|
||||||
group.push(MenuItem(props.guild.id, props.channel.id, type));
|
return MenuItem(props.guild.id, props.channel.id, type);
|
||||||
break;
|
|
||||||
case MenuItemParentType.Guild:
|
case MenuItemParentType.Guild:
|
||||||
group.push(MenuItem(props.guild.id));
|
return MenuItem(props.guild.id);
|
||||||
break;
|
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),
|
userContextMenuPatch: makeContextMenuPatch("roles", MenuItemParentType.User),
|
||||||
channelContextMenuPatch: makeContextMenuPatch("mute-channel", MenuItemParentType.Channel),
|
channelContextMenuPatch: makeContextMenuPatch(["mute-channel", "unmute-channel"], MenuItemParentType.Channel),
|
||||||
guildContextMenuPatch: makeContextMenuPatch("privacy", MenuItemParentType.Guild),
|
guildContextMenuPatch: makeContextMenuPatch("privacy", MenuItemParentType.Guild),
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 8px 5px;
|
padding: 8px 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 165px;
|
width: 230px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-list-item > div {
|
.vc-permviewer-perms-list-item > div {
|
||||||
@ -110,8 +110,8 @@
|
|||||||
|
|
||||||
.vc-permviewer-perms-perms-item-icon {
|
.vc-permviewer-perms-perms-item-icon {
|
||||||
border: 1px solid var(--background-modifier-selected);
|
border: 1px solid var(--background-modifier-selected);
|
||||||
width: 25px;
|
width: 24px;
|
||||||
height: 25px;
|
height: 24px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +121,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
scale: 0.9;
|
scale: 0.9;
|
||||||
|
transition: color ease-in 0.1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-perms-item .vc-info-icon:hover {
|
.vc-permviewer-perms-perms-item .vc-info-icon:hover {
|
||||||
|
@ -29,15 +29,15 @@ import { User } from "discord-types/general";
|
|||||||
|
|
||||||
const SessionsStore = findStoreLazy("SessionsStore");
|
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; }) => (
|
return ({ color, tooltip }: { color: string; tooltip: string; }) => (
|
||||||
<Tooltip text={tooltip} >
|
<Tooltip text={tooltip} >
|
||||||
{(tooltipProps: any) => (
|
{(tooltipProps: any) => (
|
||||||
<svg
|
<svg
|
||||||
{...tooltipProps}
|
{...tooltipProps}
|
||||||
height="20"
|
height={opts?.height ?? 20}
|
||||||
width="20"
|
width={opts?.width ?? 20}
|
||||||
viewBox={viewBox}
|
viewBox={opts?.viewBox ?? "0 0 24 24"}
|
||||||
fill={color}
|
fill={color}
|
||||||
>
|
>
|
||||||
<path d={path} />
|
<path d={path} />
|
||||||
@ -50,8 +50,8 @@ function Icon(path: string, viewBox = "0 0 24 24") {
|
|||||||
const Icons = {
|
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"),
|
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"),
|
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"),
|
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", "0 0 50 50"),
|
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;
|
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 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 || user.bot) return null;
|
||||||
|
|
||||||
if (user.id === UserStore.getCurrentUser().id) {
|
if (user.id === UserStore.getCurrentUser().id) {
|
||||||
@ -110,10 +110,11 @@ const PlatformIndicator = ({ user, wantMargin = true }: { user: User; wantMargin
|
|||||||
style={{
|
style={{
|
||||||
display: "inline-flex",
|
display: "inline-flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
marginLeft: wantMargin ? 4 : 0,
|
marginLeft: wantMargin ? 4 : 0,
|
||||||
verticalAlign: "top",
|
verticalAlign: "top",
|
||||||
position: "relative",
|
position: "relative",
|
||||||
top: wantMargin ? 1 : 0,
|
top: wantTopMargin ? 2 : 0,
|
||||||
padding: !wantMargin ? 1 : 0,
|
padding: !wantMargin ? 1 : 0,
|
||||||
gap: 2
|
gap: 2
|
||||||
}}
|
}}
|
||||||
@ -150,7 +151,7 @@ const indicatorLocations = {
|
|||||||
description: "Inside messages",
|
description: "Inside messages",
|
||||||
onEnable: () => addDecoration("platform-indicator", props =>
|
onEnable: () => addDecoration("platform-indicator", props =>
|
||||||
<ErrorBoundary noop>
|
<ErrorBoundary noop>
|
||||||
<PlatformIndicator user={props.message?.author} />
|
<PlatformIndicator user={props.message?.author} wantTopMargin={true} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
),
|
),
|
||||||
onDisable: () => removeDecoration("platform-indicator")
|
onDisable: () => removeDecoration("platform-indicator")
|
||||||
|
@ -26,10 +26,12 @@ import { settings } from "../settings";
|
|||||||
|
|
||||||
const styles: Record<string, string> = findByPropsLazy("timestampInline");
|
const styles: Record<string, string> = findByPropsLazy("timestampInline");
|
||||||
|
|
||||||
|
const AUTO_MODERATION_ACTION = 24;
|
||||||
|
|
||||||
function shouldShow(message: Message): boolean {
|
function shouldShow(message: Message): boolean {
|
||||||
if (!settings.store.showInMessages)
|
if (!settings.store.showInMessages)
|
||||||
return false;
|
return false;
|
||||||
if (message.author.bot || message.author.system)
|
if (message.author.bot || message.author.system || message.type === AUTO_MODERATION_ACTION)
|
||||||
return false;
|
return false;
|
||||||
if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,7 +38,7 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { messag
|
|||||||
// dms and group chats
|
// dms and group chats
|
||||||
const dmGroup = findGroupChildrenByChildId("pin", children);
|
const dmGroup = findGroupChildrenByChildId("pin", children);
|
||||||
if (dmGroup && !dmGroup.some(child => child?.props?.id === "reply")) {
|
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, (
|
return dmGroup.splice(pinIndex + 1, 0, (
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="reply"
|
id="reply"
|
||||||
|
@ -16,15 +16,17 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { LazyComponent } from "@utils/react";
|
import { LazyComponent } from "@utils/react";
|
||||||
import { formatDuration } from "@utils/text";
|
import { formatDuration } from "@utils/text";
|
||||||
import { find, findByPropsLazy, findStoreLazy } from "@webpack";
|
import { find, findByPropsLazy } from "@webpack";
|
||||||
import { FluxDispatcher, GuildMemberStore, GuildStore, moment, Parser, PermissionStore, SnowflakeUtils, Text, Timestamp, Tooltip } from "@webpack/common";
|
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 { Channel } from "discord-types/general";
|
||||||
import type { ComponentType } from "react";
|
import type { ComponentType } from "react";
|
||||||
|
|
||||||
import { VIEW_CHANNEL } from "..";
|
import openRolesAndUsersPermissionsModal, { PermissionType, RoleOrUserPermission } from "../../permissionsViewer/components/RolesAndUsersPermissions";
|
||||||
|
import { settings, VIEW_CHANNEL } from "..";
|
||||||
|
|
||||||
enum SortOrderTypes {
|
enum SortOrderTypes {
|
||||||
LATEST_ACTIVITY = 0,
|
LATEST_ACTIVITY = 0,
|
||||||
@ -92,7 +94,6 @@ const TagComponent = LazyComponent(() => find(m => {
|
|||||||
return code.includes(".Messages.FORUM_TAG_A11Y_FILTER_BY_TAG") && !code.includes("increasedActivityPill");
|
return code.includes(".Messages.FORUM_TAG_A11Y_FILTER_BY_TAG") && !code.includes("increasedActivityPill");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const EmojiStore = findStoreLazy("EmojiStore");
|
|
||||||
const EmojiParser = findByPropsLazy("convertSurrogateToName");
|
const EmojiParser = findByPropsLazy("convertSurrogateToName");
|
||||||
const EmojiUtils = findByPropsLazy("getURL", "buildEmojiReactionColorsPlatformed");
|
const EmojiUtils = findByPropsLazy("getURL", "buildEmojiReactionColorsPlatformed");
|
||||||
|
|
||||||
@ -124,6 +125,9 @@ const VideoQualityModesToNames = {
|
|||||||
const HiddenChannelLogo = "/assets/433e3ec4319a9d11b0cbe39342614982.svg";
|
const HiddenChannelLogo = "/assets/433e3ec4319a9d11b0cbe39342614982.svg";
|
||||||
|
|
||||||
function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
||||||
|
const [viewAllowedUsersAndRoles, setViewAllowedUsersAndRoles] = useState(settings.store.defaultAllowedUsersAndRolesDropdownState);
|
||||||
|
const [permissions, setPermissions] = useState<RoleOrUserPermission[]>([]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
topic,
|
topic,
|
||||||
@ -140,27 +144,39 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
|||||||
bitrate,
|
bitrate,
|
||||||
rtcRegion,
|
rtcRegion,
|
||||||
videoQualityMode,
|
videoQualityMode,
|
||||||
permissionOverwrites
|
permissionOverwrites,
|
||||||
|
guild_id
|
||||||
} = channel;
|
} = channel;
|
||||||
|
|
||||||
const membersToFetch: Array<string> = [];
|
useEffect(() => {
|
||||||
|
const membersToFetch: Array<string> = [];
|
||||||
|
|
||||||
const guildOwnerId = GuildStore.getGuild(channel.guild_id).ownerId;
|
const guildOwnerId = GuildStore.getGuild(guild_id).ownerId;
|
||||||
if (!GuildMemberStore.getMember(channel.guild_id, guildOwnerId)) membersToFetch.push(guildOwnerId);
|
if (!GuildMemberStore.getMember(guild_id, guildOwnerId)) membersToFetch.push(guildOwnerId);
|
||||||
|
|
||||||
Object.values(permissionOverwrites).forEach(({ type, id: userId }) => {
|
Object.values(permissionOverwrites).forEach(({ type, id: userId }) => {
|
||||||
if (type === 1) {
|
if (type === 1 && !GuildMemberStore.getMember(guild_id, userId)) {
|
||||||
if (!GuildMemberStore.getMember(channel.guild_id, userId)) membersToFetch.push(userId);
|
membersToFetch.push(userId);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (membersToFetch.length > 0) {
|
|
||||||
FluxDispatcher.dispatch({
|
|
||||||
type: "GUILD_MEMBERS_REQUEST",
|
|
||||||
guildIds: [channel.guild_id],
|
|
||||||
userIds: membersToFetch
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
if (membersToFetch.length > 0) {
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "GUILD_MEMBERS_REQUEST",
|
||||||
|
guildIds: [guild_id],
|
||||||
|
userIds: membersToFetch
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.plugins.PermissionsViewer.enabled) {
|
||||||
|
setPermissions(Object.values(permissionOverwrites).map(overwrite => ({
|
||||||
|
type: overwrite.type as PermissionType,
|
||||||
|
id: overwrite.id,
|
||||||
|
overwriteAllow: overwrite.allow,
|
||||||
|
overwriteDeny: overwrite.deny
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
}, [channelId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ChatScrollClasses.auto + " " + ChatScrollClasses.customTheme + " " + ChatClasses.chatContent + " " + "shc-lock-screen-outer-container"}>
|
<div className={ChatScrollClasses.auto + " " + ChatScrollClasses.customTheme + " " + ChatClasses.chatContent + " " + "shc-lock-screen-outer-container"}>
|
||||||
@ -182,7 +198,7 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
|||||||
aria-hidden={true}
|
aria-hidden={true}
|
||||||
role="img"
|
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>
|
</svg>
|
||||||
)}
|
)}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@ -192,7 +208,7 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
|||||||
{(!channel.isGuildVoice() && !channel.isGuildStageVoice()) && (
|
{(!channel.isGuildVoice() && !channel.isGuildStageVoice()) && (
|
||||||
<Text variant="text-lg/normal">
|
<Text variant="text-lg/normal">
|
||||||
You can not see the {channel.isForumChannel() ? "posts" : "messages"} of this channel.
|
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 >
|
</Text >
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -268,8 +284,49 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<div className="shc-lock-screen-allowed-users-and-roles-container">
|
<div className="shc-lock-screen-allowed-users-and-roles-container">
|
||||||
<Text variant="text-lg/bold">Allowed users and roles:</Text>
|
<div className="shc-lock-screen-allowed-users-and-roles-container-title">
|
||||||
<ChannelBeginHeader channel={channel} />
|
{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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,7 +39,7 @@ enum ShowMode {
|
|||||||
HiddenIconWithMutedStyle
|
HiddenIconWithMutedStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
export const settings = definePluginSettings({
|
||||||
hideUnreads: {
|
hideUnreads: {
|
||||||
description: "Hide Unreads",
|
description: "Hide Unreads",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
@ -54,6 +54,11 @@ const settings = definePluginSettings({
|
|||||||
{ label: "Muted style with hidden eye icon on the right", value: ShowMode.HiddenIconWithMutedStyle },
|
{ label: "Muted style with hidden eye icon on the right", value: ShowMode.HiddenIconWithMutedStyle },
|
||||||
],
|
],
|
||||||
restartNeeded: true
|
restartNeeded: true
|
||||||
|
},
|
||||||
|
defaultAllowedUsersAndRolesDropdownState: {
|
||||||
|
description: "Whether the allowed users and roles dropdown on hidden channels should be open by default",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,9 +33,8 @@
|
|||||||
margin: inherit;
|
margin: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shc-lock-screen-heading-nsfw-icon > path {
|
.shc-lock-screen-heading-nsfw-icon {
|
||||||
fill: var(--text-normal);
|
color: var(--text-normal);
|
||||||
fill-rule: evenodd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.shc-lock-screen-topic-container {
|
.shc-lock-screen-topic-container {
|
||||||
@ -99,6 +98,36 @@
|
|||||||
max-width: 70vw;
|
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"] {
|
.shc-lock-screen-allowed-users-and-roles-container > [class^="members"] {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
@ -59,7 +59,7 @@ export async function translate(kind: "received" | "sent", text: string): Promis
|
|||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
||||||
if (!res.ok)
|
if (!res.ok)
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to translate "${text}" (${sourceLang} -> ${targetLang}`
|
`Failed to translate "${text}" (${sourceLang} -> ${targetLang})`
|
||||||
+ `\n${res.status} ${res.statusText}`
|
+ `\n${res.status} ${res.statusText}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -41,37 +41,48 @@ export default definePlugin({
|
|||||||
],
|
],
|
||||||
execute: async (args, ctx) => {
|
execute: async (args, ctx) => {
|
||||||
try {
|
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)
|
if (!definition)
|
||||||
return void sendBotMessage(ctx.channel.id, { content: "No results found." });
|
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, {
|
return void sendBotMessage(ctx.channel.id, {
|
||||||
embeds: [
|
embeds: [
|
||||||
{
|
{
|
||||||
type: "rich",
|
type: "rich",
|
||||||
author: {
|
author: {
|
||||||
name: `Definition of ${definition.word}`,
|
name: `Uploaded by "${definition.author}"`,
|
||||||
url: definition.permalink
|
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),
|
description: linkify(definition.definition),
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "Example",
|
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,
|
color: 0xFF9900,
|
||||||
footer: { text: `👍 ${definition.thumbs_up.toString()} | 👎 ${definition.thumbs_down.toString()} | Uploaded by ${definition.author}`, icon_url: "https://www.urbandictionary.com/favicon.ico" },
|
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()
|
timestamp: new Date(definition.written_on).toISOString(),
|
||||||
}
|
},
|
||||||
] as any
|
] as any,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return void sendBotMessage(ctx.channel.id, {
|
sendBotMessage(ctx.channel.id, {
|
||||||
content: `Something went wrong: \`${error}\``
|
content: `Something went wrong: \`${error}\``,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ export default definePlugin({
|
|||||||
if (!type) continue;
|
if (!type) continue;
|
||||||
|
|
||||||
const template = Settings.plugins.VcNarrator[type + "Message"];
|
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;
|
const channel = ChannelStore.getChannel(id).name;
|
||||||
|
|
||||||
speak(formatText(template, user, channel));
|
speak(formatText(template, user, channel));
|
||||||
@ -230,6 +230,11 @@ export default definePlugin({
|
|||||||
markers: [0.1, 0.5, 1, 2, 5, 10],
|
markers: [0.1, 0.5, 1, 2, 5, 10],
|
||||||
stickToMarkers: false
|
stickToMarkers: false
|
||||||
},
|
},
|
||||||
|
sayOwnName: {
|
||||||
|
description: "Say own name",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
joinMessage: {
|
joinMessage: {
|
||||||
type: OptionType.STRING,
|
type: OptionType.STRING,
|
||||||
description: "Join Message",
|
description: "Join Message",
|
||||||
|
@ -49,6 +49,7 @@ export let RelationshipStore: Stores.RelationshipStore & t.FluxStore & {
|
|||||||
getSince(userId: string): string;
|
getSince(userId: string): string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export let EmojiStore: t.EmojiStore;
|
||||||
export let WindowStore: t.WindowStore;
|
export let WindowStore: t.WindowStore;
|
||||||
|
|
||||||
export const MaskedLinkStore = mapMangledModuleLazy('"MaskedLinkStore"', {
|
export const MaskedLinkStore = mapMangledModuleLazy('"MaskedLinkStore"', {
|
||||||
@ -87,3 +88,4 @@ waitForStore("ReadStateStore", m => ReadStateStore = m);
|
|||||||
waitForStore("GuildChannelStore", m => GuildChannelStore = m);
|
waitForStore("GuildChannelStore", m => GuildChannelStore = m);
|
||||||
waitForStore("MessageStore", m => MessageStore = m);
|
waitForStore("MessageStore", m => MessageStore = m);
|
||||||
waitForStore("WindowStore", m => WindowStore = m);
|
waitForStore("WindowStore", m => WindowStore = m);
|
||||||
|
waitForStore("EmojiStore", m => EmojiStore = m);
|
||||||
|
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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
import { FluxDispatcher, FluxEvents } from "./utils";
|
import { FluxDispatcher, FluxEvents } from "./utils";
|
||||||
|
|
||||||
export class FluxStore {
|
export class FluxStore {
|
||||||
@ -38,3 +40,102 @@ export class WindowStore extends FluxStore {
|
|||||||
isFocused(): boolean;
|
isFocused(): boolean;
|
||||||
windowSize(): Record<"width" | "height", number>;
|
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[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user