diff --git a/src/plugins/greetStickerPicker/index.tsx b/src/plugins/greetStickerPicker/index.tsx index 52f70b3c..2c8f3379 100644 --- a/src/plugins/greetStickerPicker/index.tsx +++ b/src/plugins/greetStickerPicker/index.tsx @@ -18,8 +18,9 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; +import { proxyLazy } from "@utils/lazy"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy } from "@webpack"; +import { findByProps, findByPropsLazy } from "@webpack"; import { ContextMenu, FluxDispatcher, Menu } from "@webpack/common"; import { Channel, Message } from "discord-types/general"; @@ -50,6 +51,7 @@ const settings = definePluginSettings({ }>(); const MessageActions = findByPropsLazy("sendGreetMessage"); +const WELCOME_STICKERS = proxyLazy(() => findByProps("WELCOME_STICKERS")?.WELCOME_STICKERS); function greet(channel: Channel, message: Message, stickers: string[]) { const options = MessageActions.getSendMessageOptionsForReply({ @@ -75,7 +77,7 @@ function greet(channel: Channel, message: Message, stickers: string[]) { } -function GreetMenu({ stickers, channel, message }: { stickers: Sticker[], message: Message, channel: Channel; }) { +function GreetMenu({ channel, message }: { message: Message, channel: Channel; }) { const s = settings.use(["greetMode", "multiGreetChoices"]); const { greetMode, multiGreetChoices = [] } = s; @@ -105,7 +107,7 @@ function GreetMenu({ stickers, channel, message }: { stickers: Sticker[], messag - {stickers.map(sticker => ( + {WELCOME_STICKERS.map(sticker => ( - {stickers.map(sticker => { + {WELCOME_STICKERS.map(sticker => { const checked = multiGreetChoices.some(s => s === sticker.id); return ( @@ -168,21 +170,20 @@ export default definePlugin({ { find: "Messages.WELCOME_CTA_LABEL", replacement: { - match: /innerClassName:\i\(\).welcomeCTAButton,(?<=%\i\.length;return (\i)\[\i\].+?)/, - replace: "$&onContextMenu:(e)=>$self.pickSticker(e,$1,arguments[0])," + match: /innerClassName:\i\.welcomeCTAButton,(?<={channel:\i,message:\i}=(\i).{0,400}?)/, + replace: "$&onContextMenu:(vcEvent)=>$self.pickSticker(vcEvent, $1)," } } ], pickSticker( event: React.UIEvent, - stickers: Sticker[], props: { channel: Channel, message: Message; } ) { if (!(props.message as any).deleted) - ContextMenu.open(event, () => ); + ContextMenu.open(event, () => ); } });