Plugin

NoReplyMention

Disables reply pings by default

Chat Notifications
index.tsx
Download

Source

src/plugins/noReplyMention/index.tsx
1import { definePluginSettings } from "@api/Settings";
2import { Devs } from "@utils/constants";
3import definePlugin, { OptionType } from "@utils/types";
4import type { Message } from "@vencord/discord-types";
5import { ChannelStore, GuildMemberStore } from "@webpack/common";
6
7const settings = definePluginSettings({
8 userList: {
9 description:
10 "List of user ids to allow or exempt pings for (separated by commas or spaces)",
11 type: OptionType.STRING,
12 default: "1234567890123445,1234567890123445",
13 multiline: true
14 },
15 roleList: {
16 description:
17 "List of role ids to allow or exempt pings for (separated by commas or spaces)",
18 type: OptionType.STRING,
19 default: "1234567890123445,1234567890123445",
20 multiline: true
21 },
22 shouldPingListed: {
23 description: "Behaviour",
24 type: OptionType.SELECT,
25 options: [
26 {
27 label: "Do not ping the listed users / roles",
28 value: false,
29 },
30 {
31 label: "Only ping the listed users / roles",
32 value: true,
33 default: true,
34 },
35 ],
36 },
37 inverseShiftReply: {
38 description: "Invert Discord's shift replying behaviour (enable to make shift reply mention user)",
39 type: OptionType.BOOLEAN,
40 default: false,
41 }
42});
43
44export default definePlugin({
45 name: "NoReplyMention",
46 description: "Disables reply pings by default",
47 tags: ["Chat", "Notifications"],
48 authors: [Devs.DustyAngel47, Devs.rae, Devs.pylix, Devs.outfoxxed],
49 settings,
50
51 shouldMention(message: Message, isHoldingShift: boolean) {
52 let isListed = settings.store.userList.includes(message.author.id);
53
54 const channel = ChannelStore.getChannel(message.channel_id);
55 if (channel?.guild_id && !isListed) {
56 const roles = GuildMemberStore.getMember(channel.guild_id, message.author.id)?.roles;
57 isListed = !!roles && roles.some(role => settings.store.roleList.includes(role));
58 }
59
60 const isExempt = settings.store.shouldPingListed ? isListed : !isListed;
61 return settings.store.inverseShiftReply ? isHoldingShift !== isExempt : !isHoldingShift && isExempt;
62 },
63
64 patches: [
65 {
66 find: ",\"Message\")}function",
67 replacement: {
68 match: /:(\i),shouldMention:!(\i)\.shiftKey/,
69 replace: ":$1,shouldMention:$self.shouldMention($1,$2.shiftKey)"
70 }
71 }
72 ],
73});
74