fix: greetStickerPicker (#1874)
This commit is contained in:
parent
c90440f031
commit
1a607639cc
1 changed files with 9 additions and 8 deletions
|
@ -18,8 +18,9 @@
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { proxyLazy } from "@utils/lazy";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByProps, findByPropsLazy } from "@webpack";
|
||||||
import { ContextMenu, FluxDispatcher, Menu } from "@webpack/common";
|
import { ContextMenu, FluxDispatcher, Menu } from "@webpack/common";
|
||||||
import { Channel, Message } from "discord-types/general";
|
import { Channel, Message } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ const settings = definePluginSettings({
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const MessageActions = findByPropsLazy("sendGreetMessage");
|
const MessageActions = findByPropsLazy("sendGreetMessage");
|
||||||
|
const WELCOME_STICKERS = proxyLazy(() => findByProps("WELCOME_STICKERS")?.WELCOME_STICKERS);
|
||||||
|
|
||||||
function greet(channel: Channel, message: Message, stickers: string[]) {
|
function greet(channel: Channel, message: Message, stickers: string[]) {
|
||||||
const options = MessageActions.getSendMessageOptionsForReply({
|
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 s = settings.use(["greetMode", "multiGreetChoices"]);
|
||||||
const { greetMode, multiGreetChoices = [] } = s;
|
const { greetMode, multiGreetChoices = [] } = s;
|
||||||
|
|
||||||
|
@ -105,7 +107,7 @@ function GreetMenu({ stickers, channel, message }: { stickers: Sticker[], messag
|
||||||
<Menu.MenuGroup
|
<Menu.MenuGroup
|
||||||
label="Greet Stickers"
|
label="Greet Stickers"
|
||||||
>
|
>
|
||||||
{stickers.map(sticker => (
|
{WELCOME_STICKERS.map(sticker => (
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
key={sticker.id}
|
key={sticker.id}
|
||||||
id={"greet-" + sticker.id}
|
id={"greet-" + sticker.id}
|
||||||
|
@ -123,7 +125,7 @@ function GreetMenu({ stickers, channel, message }: { stickers: Sticker[], messag
|
||||||
label="Unholy Multi-Greet"
|
label="Unholy Multi-Greet"
|
||||||
id="unholy-multi-greet"
|
id="unholy-multi-greet"
|
||||||
>
|
>
|
||||||
{stickers.map(sticker => {
|
{WELCOME_STICKERS.map(sticker => {
|
||||||
const checked = multiGreetChoices.some(s => s === sticker.id);
|
const checked = multiGreetChoices.some(s => s === sticker.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -168,21 +170,20 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "Messages.WELCOME_CTA_LABEL",
|
find: "Messages.WELCOME_CTA_LABEL",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /innerClassName:\i\(\).welcomeCTAButton,(?<=%\i\.length;return (\i)\[\i\].+?)/,
|
match: /innerClassName:\i\.welcomeCTAButton,(?<={channel:\i,message:\i}=(\i).{0,400}?)/,
|
||||||
replace: "$&onContextMenu:(e)=>$self.pickSticker(e,$1,arguments[0]),"
|
replace: "$&onContextMenu:(vcEvent)=>$self.pickSticker(vcEvent, $1),"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
pickSticker(
|
pickSticker(
|
||||||
event: React.UIEvent,
|
event: React.UIEvent,
|
||||||
stickers: Sticker[],
|
|
||||||
props: {
|
props: {
|
||||||
channel: Channel,
|
channel: Channel,
|
||||||
message: Message;
|
message: Message;
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
if (!(props.message as any).deleted)
|
if (!(props.message as any).deleted)
|
||||||
ContextMenu.open(event, () => <GreetMenu stickers={stickers} {...props} />);
|
ContextMenu.open(event, () => <GreetMenu {...props} />);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue