/* * Vencord, a Discord client mod * Copyright (c) 2024 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; import { RelationshipStore, UserStore } from "@webpack/common"; const { toggleLocalMute } = findByPropsLazy("toggleLocalMute"); const { isLocalMute } = findByPropsLazy("isLocalMute"); const settings = definePluginSettings({ autoMuteBlocked: { type: OptionType.BOOLEAN, default: true, description: "Automatically mute blocked users.", restartNeeded: false } }); export default definePlugin({ name: "MuteBlockedUsers", description: "Mute (voice) blocked users for easy recognition.", authors: [Devs.notvexi], settings, // make something useful on user block/unblock // patches: [{ // find: "renderConnectionStatus(){", // replacement: { // match: /(?<=renderConnectionStatus\(\)\{.+\.channel,children:)\i/, // replace: "[$&, $self.automaticMuteBlockedUsers()]" // } // }], automaticMuteBlockedUsers() { const { autoMuteBlocked } = settings.store; if (!autoMuteBlocked) return; const blockedIds = Object.entries(RelationshipStore.getRelationships()).filter(([k, v]) => v === 2).map(([k]) => UserStore.getUser(k).id); for (const ID of blockedIds) { if (!isLocalMute(ID)) { toggleLocalMute(ID); } } } /** * TODO: Add Context Menu to allow users mute on messages etc. */ });