mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 09:56:24 +00:00
Add settings for where you will get notified
This commit is contained in:
parent
4ac80bee4c
commit
2949815bbf
1 changed files with 27 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue