Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): WebcamStartNotifier #2780

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/plugins/webcamStartNotifier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# videoStartNotifier Plugin for Vencord
redbaron2k7 marked this conversation as resolved.
Show resolved Hide resolved

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)
redbaron2k7 marked this conversation as resolved.
Show resolved Hide resolved
43 changes: 43 additions & 0 deletions src/plugins/webcamStartNotifier/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

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";
redbaron2k7 marked this conversation as resolved.
Show resolved Hide resolved

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>();
redbaron2k7 marked this conversation as resolved.
Show resolved Hide resolved

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) {
redbaron2k7 marked this conversation as resolved.
Show resolved Hide resolved
playNotification(state.selfVideo);
}
videoStates.set(state.userId, state.selfVideo ?? false);
redbaron2k7 marked this conversation as resolved.
Show resolved Hide resolved
});
}
};
})(),
});
4 changes: 4 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
surgedevs: {
name: "Chloe",
id: 1084592643784331324n
},
redbaron2k7: {
name: "redbaron2k7",
id: 1142923640778797157n
}
} satisfies Record<string, Dev>);

Expand Down