From 0cc3901e4e1d3f98b44a502ea927703dd336c277 Mon Sep 17 00:00:00 2001 From: carince <99774021+carince@users.noreply.github.com> Date: Fri, 28 Apr 2023 10:03:38 +0800 Subject: [PATCH] MuteNewGuilds: add toggles for guild, everyone, and roles. (#979) Co-authored-by: V Co-authored-by: Norikiru <99774021+Norikiru@users.noreply.github.com> --- src/plugins/muteNewGuild.tsx | 32 +++++++++++++++++++++++++++++--- src/utils/constants.ts | 4 ++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/plugins/muteNewGuild.tsx b/src/plugins/muteNewGuild.tsx index 9be1a67..cf15b77 100644 --- a/src/plugins/muteNewGuild.tsx +++ b/src/plugins/muteNewGuild.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ +import { definePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import { ModalContent, ModalFooter, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; import { findByProps, findStoreLazy } from "@webpack"; import { Button, Text } from "@webpack/common"; @@ -49,10 +50,28 @@ function NoDMNotificationsModal({ modalProps }: { modalProps: ModalProps; }) { ); } +const settings = definePluginSettings({ + guild: { + description: "Mute Guild", + type: OptionType.BOOLEAN, + default: true + }, + everyone: { + description: "Suppress @everyone and @here", + type: OptionType.BOOLEAN, + default: true + }, + role: { + description: "Suppress All Role @mentions", + type: OptionType.BOOLEAN, + default: true + }, +}); + export default definePlugin({ name: "MuteNewGuild", description: "Mutes newly joined guilds", - authors: [Devs.Glitch, Devs.Nuckyz], + authors: [Devs.Glitch, Devs.Nuckyz, Devs.carince], patches: [ { find: ",acceptInvite:function", @@ -62,10 +81,17 @@ export default definePlugin({ } } ], + settings, handleMute(guildId: string | null) { if (guildId === "@me" || guildId === "null" || guildId == null) return; - findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(guildId, { muted: true, suppress_everyone: true, suppress_roles: true }); + findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(guildId, + { + muted: settings.store.guild, + suppress_everyone: settings.store.everyone, + suppress_roles: settings.store.role + } + ); }, start() { diff --git a/src/utils/constants.ts b/src/utils/constants.ts index d9d1067..69eb604 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -277,5 +277,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({ KannaDev: { name: "Kanna", id: 317728561106518019n + }, + carince: { + name: "carince", + id: 818323528755314698n } });