Plugin
GreetStickerPicker
Allows you to use any greet sticker instead of only the random one by right-clicking the 'Wave to say hi!' button
1
import { definePluginSettings } from "@api/Settings";2
import { Devs } from "@utils/constants";3
import definePlugin, { OptionType } from "@utils/types";4
import { Channel, Message } from "@vencord/discord-types";5
import { ContextMenuApi, FluxDispatcher, Menu, MessageActions } from "@webpack/common";6
7
enum GreetMode {8
Greet = "Greet",9
NormalMessage = "Message"10
}11
12
const settings = definePluginSettings({13
greetMode: {14
type: OptionType.SELECT,15
options: [16
{ label: "Greet (you can only greet 3 times)", value: GreetMode.Greet, default: true },17
{ label: "Normal Message (you can greet spam)", value: GreetMode.NormalMessage }18
],19
description: "Choose the greet mode"20
}21
}).withPrivateSettings<{22
multiGreetChoices?: string[];23
unholyMultiGreetEnabled?: boolean;24
}>();25
26
let WELCOME_STICKERS: any;27
28
function greet(channel: Channel, message: Message, stickers: string[]) {29
const options = MessageActions.getSendMessageOptionsForReply({30
channel,31
message,32
shouldMention: true,33
showMentionToggle: true34
});35
36
if (settings.store.greetMode === GreetMode.NormalMessage || stickers.length > 1) {37
options.stickerIds = stickers;38
const msg = {39
content: "",40
tts: false,41
invalidEmojis: [],42
validNonShortcutEmojis: []43
};44
45
MessageActions._sendMessage(channel.id, msg, options);46
} else {47
MessageActions.sendGreetMessage(channel.id, stickers[0], options);48
}49
}50
51
52
function GreetMenu({ channel, message }: { message: Message, channel: Channel; }) {53
const s = settings.use(["greetMode", "multiGreetChoices"]);54
const { greetMode, multiGreetChoices = [] } = s;55
56
return (57
<Menu.Menu58
navId="greet-sticker-picker"59
onClose={() => FluxDispatcher.dispatch({ type: "CONTEXT_MENU_CLOSE" })}60
aria-label="Greet Sticker Picker"61
>62
<Menu.MenuGroup63
label="Greet Mode"64
>65
{Object.values(GreetMode).map(mode => (66
<Menu.MenuRadioItem67
key={mode}68
group="greet-mode"69
id={"greet-mode-" + mode}70
label={mode}71
checked={mode === greetMode}72
action={() => s.greetMode = mode}73
/>74
))}75
</Menu.MenuGroup>76
77
<Menu.MenuSeparator />78
79
<Menu.MenuGroup80
label="Greet Stickers"81
>82
{WELCOME_STICKERS.map(sticker => (83
<Menu.MenuItem84
key={sticker.id}85
id={"greet-" + sticker.id}86
label={sticker.description.split(" ")[0]}87
action={() => greet(channel, message, [sticker.id])}88
/>89
))}90
</Menu.MenuGroup>91
92
{!settings.store.unholyMultiGreetEnabled ? null : (93
<>94
<Menu.MenuSeparator />95
96
<Menu.MenuItem97
label="Unholy Multi-Greet"98
id="unholy-multi-greet"99
>100
{WELCOME_STICKERS.map(sticker => {101
const checked = multiGreetChoices.some(s => s === sticker.id);102
103
return (104
<Menu.MenuCheckboxItem105
key={sticker.id}106
id={"multi-greet-" + sticker.id}107
label={sticker.description.split(" ")[0]}108
checked={checked}109
disabled={!checked && multiGreetChoices.length >= 3}110
action={() => {111
s.multiGreetChoices = checked112
? multiGreetChoices.filter(s => s !== sticker.id)113
: [...multiGreetChoices, sticker.id];114
}}115
/>116
);117
})}118
119
<Menu.MenuSeparator />120
<Menu.MenuItem121
id="multi-greet-submit"122
label="Send Greets"123
action={() => greet(channel, message, multiGreetChoices!)}124
disabled={multiGreetChoices.length === 0}125
/>126
127
</Menu.MenuItem>128
</>129
)}130
</Menu.Menu>131
);132
}133
134
export default definePlugin({135
name: "GreetStickerPicker",136
description: "Allows you to use any greet sticker instead of only the random one by right-clicking the 039;Wave to say hi!039; button",137
tags: ["Emotes", "Customisation"],138
authors: [Devs.Ven],139
140
settings,141
142
patches: [143
{144
find: "#{intl::WELCOME_CTA_LABEL}",145
replacement: {146
match: /className:\i\.\i,(?=.{0,40}?"sticker")(?<={channel:\i,message:\i}=(\i).+?)/,147
replace: "$&onContextMenu:(vcEvent)=>$self.pickSticker(vcEvent, $1),"148
}149
},150
{151
find: 039;"Wumpus waves hello"039;,152
replacement: {153
match: /(?<==)(?=\[{id:"749054660769218631",format_type:\d,description:"Wumpus waves hello")/,154
replace: "$self.WELCOME_STICKERS="155
}156
}157
],158
159
set WELCOME_STICKERS(value: any) {160
WELCOME_STICKERS = value;161
},162
163
pickSticker(164
event: React.UIEvent,165
props: {166
channel: Channel,167
message: Message;168
}169
) {170
if (!(props.message as any).deleted)171
ContextMenuApi.openContextMenu(event, () => <GreetMenu {...props} />);172
}173
});174