From 026befec322c974d583ed79ce45c7aa7f8060302 Mon Sep 17 00:00:00 2001 From: KrystalSkull <150982280+KrstlSkll69@users.noreply.github.com> Date: Wed, 20 Nov 2024 17:17:29 -0500 Subject: [PATCH 01/10] feat(plugin): Signature (#99) * add signature plugin * fix lint? --------- Co-authored-by: thororen1234 --- README.md | 1 + src/equicordplugins/signature/index.tsx | 150 ++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 src/equicordplugins/signature/index.tsx diff --git a/README.md b/README.md index 49b4eaff..54711cbf 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - SekaiStickers by MaiKokain - ServerSearch by camila314 - ShowBadgesInChat by Inbestigator & KrystalSkull +- Signature by KrystalSkull - SidebarChat by Joona - Slap by Korbo - SoundBoardLogger by Moxxie, fres, echo, maintained by thororen diff --git a/src/equicordplugins/signature/index.tsx b/src/equicordplugins/signature/index.tsx new file mode 100644 index 00000000..4df62529 --- /dev/null +++ b/src/equicordplugins/signature/index.tsx @@ -0,0 +1,150 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { addChatBarButton, ChatBarButton, removeChatBarButton } from "@api/ChatButtons"; +import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands"; +import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { MessageEvents } from "@api/index"; +import { definePluginSettings, migratePluginSettings } from "@api/Settings"; +import { EquicordDevs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { Menu, React } from "@webpack/common"; + + +// Big thank you too slientTyping + +const settings = definePluginSettings( + { + name: { + type: OptionType.STRING, + description: "The signature that will be added to the end of your messages", + default: "a chronic discord user" + }, + showIcon: { + type: OptionType.BOOLEAN, + default: true, + description: "Show an icon for toggling the plugin in the chat bar", + restartNeeded: true, + }, + contextMenu: { + type: OptionType.BOOLEAN, + description: "Add option to toggle the functionality in the chat input context menu", + default: true + }, + isEnabled: { + type: OptionType.BOOLEAN, + description: "Toggle functionality", + default: true, + }, + }); + +const SignatureToggle: ChatBarButton = ({ isMainChat }) => { + const { isEnabled, showIcon } = settings.use(["isEnabled", "showIcon"]); + const toggle = () => settings.store.isEnabled = !settings.store.isEnabled; + + if (!isMainChat || !showIcon) return null; + + return ( + + + + {isEnabled && ( + <> + + + + + )} + + + ); +}; + +// Big thank you @thororen (discord) who helped me write this const +const handleMessage = ((channelId, msg) => { if (!settings.store.isEnabled) return ""; return msg.content = textProcessing(msg.content); }); + +const ChatBarContextCheckbox: NavContextMenuPatchCallback = children => { + const { isEnabled, contextMenu } = settings.use(["isEnabled", "contextMenu"]); + if (!contextMenu) return; + + const group = findGroupChildrenByChildId("submit-button", children); + + if (!group) return; + + const idx = group.findIndex(c => c?.props?.id === "submit-button"); + + group.splice(idx + 1, 0, + settings.store.isEnabled = !settings.store.isEnabled} + /> + ); +}; + +// This is usless for the normal user but is helpful for development since I decided to rework to plugin +migratePluginSettings("Signature", "SentVia"); + +export default definePlugin({ + name: "Signature", + description: "Automated fingerprint/end text", + authors: [ + EquicordDevs.KrystalSkull + ], + dependencies: ["MessageEventsAPI", "ChatInputButtonAPI"], + + start: () => { + if (settings.store.isEnabled) true; + addChatBarButton("Signature", SignatureToggle); + // @ts-ignore + MessageEvents.addPreSendListener(handleMessage); + }, + stop: () => { + if (settings.store.isEnabled) false; + removeChatBarButton("Signature"); + // @ts-ignore + MessageEvents.removePreSendListener(handleMessage); + + }, + + settings, + + contextMenus: { + "textarea-context": ChatBarContextCheckbox + }, + + commands: [{ + name: "Signature", + description: "Toggle your signature", + inputType: ApplicationCommandInputType.BUILT_IN, + options: [ + { + name: "value", + description: "Toggle your signature (default is toggle)", + required: false, + type: ApplicationCommandOptionType.BOOLEAN, + }, + ], + execute: async (args, ctx) => { + settings.store.isEnabled = !!findOption(args, "value", !settings.store.isEnabled); + sendBotMessage(ctx.channel.id, { + content: settings.store.isEnabled ? "Signature enabled!" : "Signature disabled!", + }); + }, + }], +}); + + +// text processing injection processor +function textProcessing(input: string) { + return `${input}\n> ${settings.store.name}`; +} + + From 656a0168cc123d870186b334ccdf713c6e2e66af Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Wed, 20 Nov 2024 17:27:44 -0500 Subject: [PATCH 02/10] Signature Fixes --- src/equicordplugins/remixMe/index.tsx | 7 +++---- src/equicordplugins/signature/index.tsx | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/equicordplugins/remixMe/index.tsx b/src/equicordplugins/remixMe/index.tsx index 7df5cf97..473eed84 100644 --- a/src/equicordplugins/remixMe/index.tsx +++ b/src/equicordplugins/remixMe/index.tsx @@ -6,8 +6,7 @@ import "./style.css"; -import { MessageEvents } from "@api/index"; -import { MessageExtra, MessageObject } from "@api/MessageEvents"; +import { addPreSendListener, MessageExtra, MessageObject, removePreSendListener } from "@api/MessageEvents"; import { EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Forms } from "@webpack/common"; @@ -23,6 +22,6 @@ export default definePlugin({ We can't guarantee this plugin won't get you warned or banned. , - start: () => MessageEvents.addPreSendListener(handleMessage), - stop: () => MessageEvents.removePreSendListener(handleMessage) + start: () => addPreSendListener(handleMessage), + stop: () => removePreSendListener(handleMessage) }); diff --git a/src/equicordplugins/signature/index.tsx b/src/equicordplugins/signature/index.tsx index 4df62529..cc310588 100644 --- a/src/equicordplugins/signature/index.tsx +++ b/src/equicordplugins/signature/index.tsx @@ -7,13 +7,12 @@ import { addChatBarButton, ChatBarButton, removeChatBarButton } from "@api/ChatButtons"; import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands"; import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; -import { MessageEvents } from "@api/index"; +import { addPreSendListener, removePreSendListener } from "@api/MessageEvents"; import { definePluginSettings, migratePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Menu, React } from "@webpack/common"; - // Big thank you too slientTyping const settings = definePluginSettings( @@ -66,8 +65,13 @@ const SignatureToggle: ChatBarButton = ({ isMainChat }) => { ); }; -// Big thank you @thororen (discord) who helped me write this const -const handleMessage = ((channelId, msg) => { if (!settings.store.isEnabled) return ""; return msg.content = textProcessing(msg.content); }); +const handleMessage = ((channelId, msg) => { + if (!settings.store.isEnabled) { + msg.content = msg.content; + } else { + msg.content = textProcessing(msg.content); + } +}); const ChatBarContextCheckbox: NavContextMenuPatchCallback = children => { const { isEnabled, contextMenu } = settings.use(["isEnabled", "contextMenu"]); @@ -89,7 +93,6 @@ const ChatBarContextCheckbox: NavContextMenuPatchCallback = children => { ); }; -// This is usless for the normal user but is helpful for development since I decided to rework to plugin migratePluginSettings("Signature", "SentVia"); export default definePlugin({ @@ -103,14 +106,12 @@ export default definePlugin({ start: () => { if (settings.store.isEnabled) true; addChatBarButton("Signature", SignatureToggle); - // @ts-ignore - MessageEvents.addPreSendListener(handleMessage); + addPreSendListener(handleMessage); }, stop: () => { if (settings.store.isEnabled) false; removeChatBarButton("Signature"); - // @ts-ignore - MessageEvents.removePreSendListener(handleMessage); + removePreSendListener(handleMessage); }, From f52625e97fff38859df574c8c3be7842bae3f158 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 21 Nov 2024 18:57:45 -0500 Subject: [PATCH 03/10] Fix Author Line --- src/equicordplugins/signature/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/equicordplugins/signature/index.tsx b/src/equicordplugins/signature/index.tsx index cc310588..5536ae69 100644 --- a/src/equicordplugins/signature/index.tsx +++ b/src/equicordplugins/signature/index.tsx @@ -98,9 +98,7 @@ migratePluginSettings("Signature", "SentVia"); export default definePlugin({ name: "Signature", description: "Automated fingerprint/end text", - authors: [ - EquicordDevs.KrystalSkull - ], + authors: [EquicordDevs.KrystalSkull], dependencies: ["MessageEventsAPI", "ChatInputButtonAPI"], start: () => { From 1c33f60fa646ed76fc56b43135dba7b028ba60ed Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 21 Nov 2024 19:16:50 -0500 Subject: [PATCH 04/10] Update UserPFP Backup URL --- src/equicordplugins/userpfp/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equicordplugins/userpfp/index.tsx b/src/equicordplugins/userpfp/index.tsx index 99613667..9f0ebccf 100644 --- a/src/equicordplugins/userpfp/index.tsx +++ b/src/equicordplugins/userpfp/index.tsx @@ -34,7 +34,7 @@ const settings = definePluginSettings({ }, { label: "UserPFP Backup DB", - value: "https://userpfp.thororen.com/UserPFP/source/data.json" + value: "https://userpfp.thororen.com/data.json" } ] } From 13993f3f69d587c247900589a88e4264cc57b0c8 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:01:58 -0500 Subject: [PATCH 05/10] Decor: Fix avatar decorations not showing (again) (#3025) --- src/plugins/consoleJanitor/index.ts | 21 --------------------- src/webpack/common/utils.ts | 4 ++-- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index a02fcad1..2c29bf67 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -130,27 +130,6 @@ export default definePlugin({ replace: "" } }, - // Zustand section - { - find: "[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.", - replacement: [ - { - match: /&&console\.warn\("\[DEPRECATED\] Passing a vanilla store will be unsupported in a future version\. Instead use `import { useStore } from 'zustand'`\."\)/, - replace: "" - }, - { - match: /console\.warn\("\[DEPRECATED\] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`\. They can be imported from 'zustand\/traditional'\. https:\/\/github\.com\/pmndrs\/zustand\/discussions\/1937"\),/, - replace: "" - } - ] - }, - { - find: "[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead.", - replacement: { - match: /console\.warn\("\[DEPRECATED\] `getStorage`, `serialize` and `deserialize` options are deprecated\. Use `storage` option instead\."\),/, - replace: "" - } - }, // Patches discords generic logger function { find: "Σ:", diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index 4b1959b5..dc337a2e 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -163,8 +163,8 @@ waitFor(["open", "saveAccountChanges"], m => SettingsRouter = m); export const PermissionsBits: t.PermissionsBits = findLazy(m => typeof m.ADMINISTRATOR === "bigint"); -export const { zustandCreate } = mapMangledModuleLazy(["useSyncExternalStoreWithSelector:", "Object.assign", /(\i)\?(\i)\(\1\):\2/], { - zustandCreate: filters.byCode(/(\i)\?(\i)\(\1\):\2/) +export const { zustandCreate } = mapMangledModuleLazy(["useSyncExternalStoreWithSelector:", "Object.assign"], { + zustandCreate: filters.byCode(/=>(\i)\?\i\(\1/) }); export const { zustandPersist } = mapMangledModuleLazy(".onRehydrateStorage)?", { From ac1b1d44f5d994cd8d3c44e58f28bd1d76842cef Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:03:59 -0500 Subject: [PATCH 06/10] ShowHiddenChannels: Fix viewing voice channels (#3033) --- src/plugins/showHiddenChannels/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index ba367542..6b67aee8 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -103,7 +103,7 @@ export default definePlugin({ replacement: [ { // Do not show confirmation to join a voice channel when already connected to another if clicking on a hidden voice channel - match: /(?<=getBlockedUsersForVoiceChannel\((\i)\.id\);return\()/, + match: /(?<=getIgnoredUsersForVoiceChannel\((\i)\.id\);return\()/, replace: (_, channel) => `!$self.isHiddenChannel(${channel})&&` }, { From f22d0e14a42fc600a4768afd3855cd5959829b81 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:07:46 -0500 Subject: [PATCH 07/10] EmoteCloner: Fix recognizing animated emojis (#3027) --- src/plugins/emoteCloner/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/emoteCloner/index.tsx b/src/plugins/emoteCloner/index.tsx index 6dd3eb30..1b26e2f0 100644 --- a/src/plugins/emoteCloner/index.tsx +++ b/src/plugins/emoteCloner/index.tsx @@ -310,7 +310,8 @@ function buildMenuItem(type: "Emoji" | "Sticker", fetchData: () => Promisable { From f8dfe217b11844c2a08c1d3890def4a82cb192b8 Mon Sep 17 00:00:00 2001 From: Cassie <37855219+CodeF53@users.noreply.github.com> Date: Sat, 23 Nov 2024 19:08:53 -0700 Subject: [PATCH 08/10] Remove no-longer desired collaborator (#3032) --- src/plugins/clientTheme/index.tsx | 2 +- src/utils/constants.ts | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/clientTheme/index.tsx b/src/plugins/clientTheme/index.tsx index 7e648427..4c1668aa 100644 --- a/src/plugins/clientTheme/index.tsx +++ b/src/plugins/clientTheme/index.tsx @@ -110,7 +110,7 @@ const settings = definePluginSettings({ export default definePlugin({ name: "ClientTheme", - authors: [Devs.F53, Devs.Nuckyz], + authors: [Devs.Nuckyz], description: "Recreation of the old client theme experiment. Add a color to your Discord client theme", settings, diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 362a22de..e7582591 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -267,10 +267,6 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "arHSM", id: 841509053422632990n }, - F53: { - name: "Cassie (Code)", - id: 280411966126948353n - }, AutumnVN: { name: "AutumnVN", id: 393694671383166998n From 7ca4ea3d136db420e29f82535b2c6f1d59e6aa28 Mon Sep 17 00:00:00 2001 From: Hen <68553709+henmalib@users.noreply.github.com> Date: Sun, 24 Nov 2024 03:16:41 +0100 Subject: [PATCH 09/10] RoleColorEverywhere: Fix message headers colors (#3036) --- src/plugins/roleColorEverywhere/index.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/plugins/roleColorEverywhere/index.tsx b/src/plugins/roleColorEverywhere/index.tsx index 090c35d3..7b811943 100644 --- a/src/plugins/roleColorEverywhere/index.tsx +++ b/src/plugins/roleColorEverywhere/index.tsx @@ -156,7 +156,7 @@ export default definePlugin({ find: "#{intl::MESSAGE_EDITED}", replacement: { match: /(?<=isUnsupported\]:(\i)\.isUnsupported\}\),)(?=children:\[)/, - replace: "style:$self.useMessageColorStyle($1)," + replace: "style:$self.useMessageColorsStyle($1)," }, predicate: () => settings.store.colorChatMessages } @@ -188,13 +188,19 @@ export default definePlugin({ }; }, - useMessageColor(message: any) { + useMessageColorsStyle(message: any) { try { const { messageSaturation } = settings.use(["messageSaturation"]); const author = useMessageAuthor(message); if (author.colorString != null && messageSaturation !== 0) { - return `color-mix(in oklab, ${author.colorString} ${messageSaturation}%, var(--text-normal))`; + const value = `color-mix(in oklab, ${author.colorString} ${messageSaturation}%, var({DEFAULT}))`; + + return { + color: value.replace("{DEFAULT}", "--text-normal"), + "--header-primary": value.replace("{DEFAULT}", "--header-primary"), + "--text-muted": value.replace("{DEFAULT}", "--text-muted") + }; } } catch (e) { new Logger("RoleColorEverywhere").error("Failed to get message color", e); @@ -203,14 +209,6 @@ export default definePlugin({ return null; }, - useMessageColorStyle(message: any) { - const color = this.useMessageColor(message); - - return color && { - color - }; - }, - RoleGroupColor: ErrorBoundary.wrap(({ id, count, title, guildId, label }: { id: string; count: number; title: string; guildId: string; label: string; }) => { const role = GuildStore.getRole(guildId, id); From 2bfeef88caa95d8af170807666c8595818fb2c48 Mon Sep 17 00:00:00 2001 From: samara Date: Sat, 23 Nov 2024 18:23:03 -0800 Subject: [PATCH 10/10] Update to newer Discord icons in Vencord Settings (#3029) --- src/components/Icons.tsx | 52 +++++++++++-------- .../PluginSettings/LinkIconButton.tsx | 7 ++- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/components/Icons.tsx b/src/components/Icons.tsx index d0d2ecbe..e48cfe5f 100644 --- a/src/components/Icons.tsx +++ b/src/components/Icons.tsx @@ -18,7 +18,7 @@ import "./iconStyles.css"; -import { getIntlMessage, getTheme, Theme } from "@utils/discord"; +import { getIntlMessage } from "@utils/discord"; import { classes } from "@utils/misc"; import type { PropsWithChildren } from "react"; @@ -122,8 +122,8 @@ export function InfoIcon(props: IconProps) { > ); @@ -211,9 +211,10 @@ export function CogWheel(props: IconProps) { viewBox="0 0 24 24" > ); @@ -406,23 +407,30 @@ export function PencilIcon(props: IconProps) { ); } -const WebsiteIconDark = "/assets/e1e96d89e192de1997f73730db26e94f.svg"; -const WebsiteIconLight = "/assets/730f58bcfd5a57a5e22460c445a0c6cf.svg"; -const GithubIconLight = "/assets/3ff98ad75ac94fa883af5ed62d17c459.svg"; -const GithubIconDark = "/assets/6a853b4c87fce386cbfef4a2efbacb09.svg"; - -export function GithubIcon(props: ImageProps) { - const src = getTheme() === Theme.Light - ? GithubIconLight - : GithubIconDark; - - return ; +export function GithubIcon(props: IconProps) { + return ( + + + + ); } -export function WebsiteIcon(props: ImageProps) { - const src = getTheme() === Theme.Light - ? WebsiteIconLight - : WebsiteIconDark; - - return ; +export function WebsiteIcon(props: IconProps) { + return ( + + + + ); } diff --git a/src/components/PluginSettings/LinkIconButton.tsx b/src/components/PluginSettings/LinkIconButton.tsx index dd840f52..4dae0e1e 100644 --- a/src/components/PluginSettings/LinkIconButton.tsx +++ b/src/components/PluginSettings/LinkIconButton.tsx @@ -6,16 +6,19 @@ import "./LinkIconButton.css"; +import { getTheme, Theme } from "@utils/discord"; import { MaskedLink, Tooltip } from "@webpack/common"; import { GithubIcon, WebsiteIcon } from ".."; export function GithubLinkIcon() { - return ; + const theme = getTheme() === Theme.Light ? "#000000" : "#FFFFFF"; + return ; } export function WebsiteLinkIcon() { - return ; + const theme = getTheme() === Theme.Light ? "#000000" : "#FFFFFF"; + return ; } interface Props {