1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-10 09:56:24 +00:00

WebcamStartNotifier

This commit is contained in:
redbaron2k7 2024-08-13 12:12:41 -06:00
parent 5160f906f4
commit c01773e932
3 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1,5 @@
# videoStartNotifier Plugin for Vencord
Plays a sound notification when a user starts/stops their video in a voice chat. The sounds are the stream start/stop sounds but modified pitch
Idea from [Vencord Plugin Request #1026](https://github.com/Vencord/plugin-requests/issues/1026)

View file

@ -0,0 +1,37 @@
import definePlugin from "@utils/types";
import { SelectedChannelStore } from "@webpack/common";
import { Devs } from "@utils/constants";
const startSound = "https://raw.githubusercontent.com/redbaron2k7/videoStartNotifier//main/start.mp3";
const stopSound = "https://raw.githubusercontent.com/redbaron2k7/videoStartNotifier/main/stop.mp3";
function playNotification(isVideoOn: boolean) {
new Audio(isVideoOn ? startSound : stopSound).play();
}
export default definePlugin({
name: "WebcamStartNotifier",
description: "Plays a sound when someone starts/stops their webcam in a voice channel",
authors: [Devs.redbaron2k7],
flux: (() => {
const videoStates = new Map<string, boolean>();
return {
VOICE_STATE_UPDATES: ({ voiceStates }: { voiceStates: Array<{ userId: string, channelId: string, selfVideo?: boolean; }>; }) => {
const currentChannelId = SelectedChannelStore.getVoiceChannelId();
if (!currentChannelId) return;
voiceStates.forEach(state => {
if (state.channelId !== currentChannelId) return;
const prevVideoState = videoStates.get(state.userId);
if (state.selfVideo !== undefined && prevVideoState !== undefined && prevVideoState !== state.selfVideo) {
playNotification(state.selfVideo);
}
videoStates.set(state.userId, state.selfVideo ?? false);
});
}
};
})(),
});

View file

@ -545,6 +545,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
surgedevs: {
name: "Chloe",
id: 1084592643784331324n
},
redbaron2k7: {
name: "redbaron2k7",
id: 1142923640778797157n
}
} satisfies Record<string, Dev>);