mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
WebcamStartNotifier
This commit is contained in:
parent
5160f906f4
commit
c01773e932
3 changed files with 46 additions and 0 deletions
5
src/plugins/webcamStartNotifier/README.md
Normal file
5
src/plugins/webcamStartNotifier/README.md
Normal 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)
|
37
src/plugins/webcamStartNotifier/index.ts
Normal file
37
src/plugins/webcamStartNotifier/index.ts
Normal 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(),
|
||||||
|
});
|
|
@ -545,6 +545,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
surgedevs: {
|
surgedevs: {
|
||||||
name: "Chloe",
|
name: "Chloe",
|
||||||
id: 1084592643784331324n
|
id: 1084592643784331324n
|
||||||
|
},
|
||||||
|
redbaron2k7: {
|
||||||
|
name: "redbaron2k7",
|
||||||
|
id: 1142923640778797157n
|
||||||
}
|
}
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue