Skip to content

Commit

Permalink
Merge branch 'askMeToMute' into sqaaakoi-stable-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sqaaakoi committed Jul 8, 2024
2 parents 739e6e5 + 538a32f commit 9976914
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/plugins/askMeToMute/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { PermissionsBits, PermissionStore, UserStore } from "@webpack/common";

const { toggleSelfMute } = findByPropsLazy("toggleSelfMute");
const { setServerMute } = findByPropsLazy("setServerMute");

interface VoiceState {
guildId?: string;
channelId?: string;
mute: boolean;
selfMute: boolean;
userId: string;
}

export default definePlugin({
name: "AskMeToMute",
description: "Mute yourself when moderators server mute you, and automatically remove your server mute if you have permission.",
authors: [Devs.Sqaaakoi],

flux: {
VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
if (!voiceStates) return;
voiceStates.forEach(state => {
if (state.userId !== UserStore.getCurrentUser().id) return;
if (!state.guildId) return;
if (!(state.mute && !state.selfMute)) return;
toggleSelfMute({ playSoundEffect: false });
if (PermissionStore.canWithPartialContext(PermissionsBits.MUTE_MEMBERS, { channelId: state.channelId })) setServerMute(state.guildId, state.userId, false);
});
}
}
});

0 comments on commit 9976914

Please sign in to comment.