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:
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
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { SelectedChannelStore } from "@webpack/common";
|
import { SelectedChannelStore, ChannelStore } from "@webpack/common";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
|
||||||
const startSound = "https://raw.githubusercontent.com/redbaron2k7/videoStartNotifier/117738bff76699a89531a067e321b6406bffbc88/start.mp3";
|
const startSound = "https://raw.githubusercontent.com/redbaron2k7/videoStartNotifier/117738bff76699a89531a067e321b6406bffbc88/start.mp3";
|
||||||
const stopSound = "https://raw.githubusercontent.com/redbaron2k7/videoStartNotifier/117738bff76699a89531a067e321b6406bffbc88/stop.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();
|
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({
|
export default definePlugin({
|
||||||
name: "WebcamStartNotifier",
|
name: "WebcamStartNotifier",
|
||||||
description: "Plays a sound when someone starts/stops their webcam in a voice channel",
|
description: "Plays a sound when someone starts/stops their webcam in a voice channel",
|
||||||
authors: [Devs.redbaron2k7],
|
authors: [Devs.redbaron2k7],
|
||||||
|
settings,
|
||||||
|
|
||||||
flux: (() => {
|
flux: (() => {
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +43,16 @@ export default definePlugin({
|
||||||
const currentChannelId = SelectedChannelStore.getVoiceChannelId();
|
const currentChannelId = SelectedChannelStore.getVoiceChannelId();
|
||||||
if (!currentChannelId) return;
|
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 => {
|
voiceStates.forEach(state => {
|
||||||
if (state.channelId !== currentChannelId) return;
|
if (state.channelId !== currentChannelId) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue