MuteNewGuilds: add toggles for guild, everyone, and roles. (#979)

Co-authored-by: V <vendicated@riseup.net>
Co-authored-by: Norikiru <99774021+Norikiru@users.noreply.github.com>
This commit is contained in:
carince 2023-04-28 10:03:38 +08:00 committed by GitHub
parent f8ace5b53a
commit 0cc3901e4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View file

@ -16,9 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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() {

View file

@ -277,5 +277,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({
KannaDev: {
name: "Kanna",
id: 317728561106518019n
},
carince: {
name: "carince",
id: 818323528755314698n
}
});