1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-10 18:06:22 +00:00

Add settings for where you will get notified

This commit is contained in:
redbaron2k7 2024-08-14 14:43:47 -06:00
parent 4ac80bee4c
commit 2949815bbf

View file

@ -4,9 +4,10 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import definePlugin from "@utils/types";
import { SelectedChannelStore } from "@webpack/common";
import definePlugin, { OptionType } from "@utils/types";
import { SelectedChannelStore, ChannelStore } from "@webpack/common";
import { Devs } from "@utils/constants";
import { definePluginSettings } from "@api/Settings";
const startSound = "https://raw.githubusercontent.com/redbaron2k7/videoStartNotifier/117738bff76699a89531a067e321b6406bffbc88/start.mp3";
const stopSound = "https://raw.githubusercontent.com/redbaron2k7/videoStartNotifier/117738bff76699a89531a067e321b6406bffbc88/stop.mp3";
@ -17,10 +18,24 @@ function playNotification(isVideoOn: boolean) {
new Audio(isVideoOn ? startSound : stopSound).play();
}
const settings = definePluginSettings({
playInPrivate: {
type: OptionType.BOOLEAN,
description: "Play notification sound in private voice calls (DMs)",
default: true
},
playInServer: {
type: OptionType.BOOLEAN,
description: "Play notification sound in server voice channels",
default: true
}
});
export default definePlugin({
name: "WebcamStartNotifier",
description: "Plays a sound when someone starts/stops their webcam in a voice channel",
authors: [Devs.redbaron2k7],
settings,
flux: (() => {
return {
@ -28,6 +43,16 @@ export default definePlugin({
const currentChannelId = SelectedChannelStore.getVoiceChannelId();
if (!currentChannelId) return;
const currentChannel = ChannelStore.getChannel(currentChannelId);
if (!currentChannel) return;
const isPrivateChannel = currentChannel.type === 1 || currentChannel.type === 3;
if ((isPrivateChannel && !settings.store.playInPrivate) ||
(!isPrivateChannel && !settings.store.playInServer)) {
return;
}
voiceStates.forEach(state => {
if (state.channelId !== currentChannelId) return;