From a31c80ba509fb56ff6f8105af08cb149234af3e2 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sat, 6 Jun 2026 19:59:19 -0400 Subject: [PATCH] Fix InstantScreenshare, WigglyText, ExitSounds --- src/equicordplugins/exitSounds/index.tsx | 62 +++++++++---------- .../instantScreenshare/utils.tsx | 5 +- src/equicordplugins/wigglyText/index.tsx | 49 ++++++++++----- 3 files changed, 64 insertions(+), 52 deletions(-) diff --git a/src/equicordplugins/exitSounds/index.tsx b/src/equicordplugins/exitSounds/index.tsx index 4273c32e0..8e9fe8d1f 100644 --- a/src/equicordplugins/exitSounds/index.tsx +++ b/src/equicordplugins/exitSounds/index.tsx @@ -14,7 +14,7 @@ import { Devs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import definePlugin, { OptionType } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; -import { ChannelActions, Constants, GuildStore, IconUtils, MediaEngineStore, Menu, RestAPI, SearchableSelect, SelectedChannelStore, TextInput, Toasts } from "@webpack/common"; +import { Constants, GuildStore, IconUtils, MediaEngineStore, Menu, RestAPI, SearchableSelect, SelectedChannelStore, TextInput, Toasts } from "@webpack/common"; const cl = classNameFactory("vc-exitsounds-"); @@ -99,8 +99,6 @@ const SoundButtonContext: NavContextMenuPatchCallback = (children, { sound }: { ); }; -let original: typeof ChannelActions.selectVoiceChannel; - export default definePlugin({ name: "ExitSounds", description: "Play soundboard sounds when you disconnect from voice.", @@ -108,41 +106,39 @@ export default definePlugin({ authors: [Devs.prism], dependencies: ["AudioPlayerAPI"], settings, - contextMenus: { "sound-button-context": SoundButtonContext }, - - start() { - original = ChannelActions.selectVoiceChannel; - ChannelActions.selectVoiceChannel = async (id: string | null, ...args: unknown[]) => { - const { soundGuildId, soundId } = settings.store; - const voiceId = SelectedChannelStore.getVoiceChannelId(); - - if (soundGuildId && soundId && voiceId !== id && !MediaEngineStore.isDeaf()) { - try { - await RestAPI.post({ - url: Constants.Endpoints.SEND_SOUNDBOARD_SOUND(voiceId), - body: { - sound_id: soundId, - source_guild_id: soundGuildId - } - }); - await new Promise(r => setTimeout(r, 500)); - } catch { - Toasts.show({ - message: "Oops! Something went wrong.", - id: Toasts.genId(), - type: Toasts.Type.FAILURE - }); - } + patches: [ + { + find: 'type:"VOICE_CHANNEL_SHOW_FEEDBACK"', + replacement: { + match: /disconnect\(\)\{/, + replace: "async $& await $self.onDisconnect();" } + } + ], + async onDisconnect() { + const { soundGuildId, soundId } = settings.store; + if (!soundGuildId || !soundId || MediaEngineStore.isDeaf()) return; - return original(id, ...args); - }; - }, + const voiceId = SelectedChannelStore.getVoiceChannelId(); + if (!voiceId) return; - stop() { - ChannelActions.selectVoiceChannel = original; + try { + await RestAPI.post({ + url: Constants.Endpoints.SEND_SOUNDBOARD_SOUND(voiceId), + body: { + sound_id: soundId, + source_guild_id: soundGuildId + } + }); + } catch { + Toasts.show({ + message: "Oops! Something went wrong.", + id: Toasts.genId(), + type: Toasts.Type.FAILURE + }); + } } }); diff --git a/src/equicordplugins/instantScreenshare/utils.tsx b/src/equicordplugins/instantScreenshare/utils.tsx index 22ac85cea..72fbe75d3 100644 --- a/src/equicordplugins/instantScreenshare/utils.tsx +++ b/src/equicordplugins/instantScreenshare/utils.tsx @@ -8,6 +8,7 @@ import { definePluginSettings } from "@api/Settings"; import { Heading } from "@components/Heading"; import { Margins } from "@components/margins"; import { Paragraph } from "@components/Paragraph"; +import { IS_WINDOWS } from "@utils/constants"; import { Logger } from "@utils/Logger"; import { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy } from "@webpack"; @@ -68,7 +69,7 @@ export const settings = definePluginSettings({ export async function getCurrentMedia() { const media = MediaEngineStore.getMediaEngine(); - const sources = await getDesktopSources(media, ["screen", "window"], null) ?? []; + const sources = await getDesktopSources(media, IS_WINDOWS, ["screen", "window"], null) ?? []; if (settings.store.includeVideoDevices) { try { @@ -122,7 +123,7 @@ function ScreenSetting() { let active = true; async function fetchMedia() { setLoading(true); - const sources = await getDesktopSources(media, ["screen", "window"], null) ?? []; + const sources = await getDesktopSources(media, IS_WINDOWS, ["screen", "window"], null) ?? []; if (includeVideoDevices) { try { diff --git a/src/equicordplugins/wigglyText/index.tsx b/src/equicordplugins/wigglyText/index.tsx index b3118029f..168a3a2d9 100644 --- a/src/equicordplugins/wigglyText/index.tsx +++ b/src/equicordplugins/wigglyText/index.tsx @@ -128,33 +128,48 @@ export default definePlugin({ patches: [ { - find: "parseToAST:", + find: "AUTO_MODERATION_SYSTEM_MESSAGE_RULES:", replacement: { - match: /(parse[\w]*):(.*?)\((\i)\),/g, - replace: "$1:$2({...$3,wiggly:$self.wigglyRule}),", + match: /staticRouteLink:\{order:(\i\.\i\.order)/, + replace: "wiggly:$self.wigglyRule($1),$&", }, }, + { + find: 'before:"@silent"', + replacement: [ + { + match: /staticRouteLink:{type:/, + replace: 'wiggly:{type:"inlineObject"},$&', + }, + { + match: /case"roleMention":/, + replace: '$&case "wiggly":' + } + ] + }, ], - wigglyRule: { - order: 24, - match: (source: string) => classMap.map(({ chars }) => source.match(new RegExp(`^(\\${chars[0]})~([\\s\\S]+?)~(\\${chars[1]})(?!_)`))).find(x => x !== null), - parse: ( - capture: RegExpMatchArray, - transform: (...args: any[]) => any, - state: any - ) => { - const className = classMap.find(({ chars }) => chars[0] === capture[1] && chars[1] === capture[3])?.className ?? ""; + wigglyRule: (order: number) => ({ + order: order, + requiredFirstCharacters: ["<~", "^~", ")~"], + match(source: string) { + return classMap + .map(({ chars }) => source.match( + new RegExp(`^(\\${chars[0]})~([\\s\\S]+?)~(\\${chars[1]})(?!_)`) + )) + .find(x => x !== null); + }, + parse(capture: RegExpMatchArray, transform: (...args: any[]) => any, state: any) { + const className = classMap + .find(({ chars }) => chars[0] === capture[1] && chars[1] === capture[3])?.className + ?? ""; return { content: transform(capture[2], state), className }; }, - react: ( - data: { content: any[]; className: string; }, - output: (...args: any[]) => ReactNode[] - ) => { + react(data: { content: any[]; className: string; }, output: (...args: any[]) => ReactNode[]) { let offset = 0; const traverse = (raw: any) => { const children = !Array.isArray(raw) ? [raw] : raw; @@ -186,7 +201,7 @@ export default definePlugin({ return traverse(output(data.content)); }, - }, + }), start: () => { styles = document.createElement("style");