From f6122a00ca9d5259ca8c97e88045ee9b9936ab70 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 15 Dec 2022 11:05:44 -0300 Subject: [PATCH] feat(NoReplyMention): exempt list support (#337) --- .../{noReplyMention.ts => noReplyMention.tsx} | 35 +++++++++++++++---- src/utils/constants.ts | 4 +++ 2 files changed, 33 insertions(+), 6 deletions(-) rename src/plugins/{noReplyMention.ts => noReplyMention.tsx} (56%) diff --git a/src/plugins/noReplyMention.ts b/src/plugins/noReplyMention.tsx similarity index 56% rename from src/plugins/noReplyMention.ts rename to src/plugins/noReplyMention.tsx index 620274c6..91a88d30 100644 --- a/src/plugins/noReplyMention.ts +++ b/src/plugins/noReplyMention.tsx @@ -16,20 +16,43 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; + +interface Reply { + message: { + author: { + id: string; + }; + }; +} export default definePlugin({ name: "NoReplyMention", description: "Disables reply pings by default", - authors: [Devs.DustyAngel47], + authors: [Devs.DustyAngel47, Devs.axyie], + options: { + exemptList: { + description: + "List of users to exempt from this plugin (separated by commas)", + type: OptionType.STRING, + default: "1234567890123445,1234567890123445", + }, + }, + shouldMention(reply: Reply) { + return Settings.plugins.NoReplyMention.exemptList.includes( + reply.message.author.id + ); + }, patches: [ { find: "CREATE_PENDING_REPLY:function", replacement: { match: /CREATE_PENDING_REPLY:function\((.{1,2})\){/, - replace: "CREATE_PENDING_REPLY:function($1){$1.shouldMention=false;" - } - } - ] + replace: + "CREATE_PENDING_REPLY:function($1){$1.shouldMention=Vencord.Plugins.plugins.NoReplyMention.shouldMention($1);", + }, + }, + ], }); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index faff7321..6c7b540c 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -173,4 +173,8 @@ export const Devs = Object.freeze({ name: "ActuallyTheSun", id: 406028027768733696n }, + axyie: { + name: "'ax", + id: 273562710745284628n, + }, });