fix(gateway): detect camera-only video (selfVideo) for stream watch

Previously only member.voice.streaming (screen share, self_stream) triggered
video capture. Discord reports camera via self_video:true, so camera-only
users were never watched. Now scanExistingStreamers and handleVoiceStateUpdate
start a watch when streaming OR selfVideo is set, and stop it when both clear.
This commit is contained in:
asepharyana
2026-09-01 22:26:38 +07:00
parent c9ad75b512
commit 1367a2257f
@@ -96,8 +96,13 @@ export function scanExistingStreamers(channel: VoiceChannel): void {
if (!members || members.size === 0) return;
let watched = 0;
for (const [, member] of members) {
const vs = member.voice?.streaming;
if (vs && member.id !== _client?.user?.id) {
// Watch anyone with video ACTIVE: screen share (streaming) OR camera
// (selfVideo). Camera on Discord (mobile/desktop "video") is reported via
// self_video:true, NOT self_stream — previously only streaming was checked
// so camera-only users were never watched.
const vs = member.voice;
const hasVideo = Boolean(vs?.streaming || vs?.selfVideo);
if (hasVideo && member.id !== _client?.user?.id) {
startVideoRecording(channel, member.id);
watched++;
}
@@ -129,11 +134,13 @@ async function handleVoiceStateUpdate(
if (!channel) return; // not an actively-recorded channel
const streaming = Boolean(newState.streaming);
const cameraOn = Boolean(newState.selfVideo);
const hasVideo = streaming || cameraOn;
const inChannel = newState.channelId === channel.id;
if (streaming && inChannel) {
if (hasVideo && inChannel) {
startVideoRecording(channel, newState.id);
} else if (!inChannel || !streaming) {
} else if (!inChannel || !hasVideo) {
stopVideoRecording(channel.guild.id, newState.id);
}
} catch (err) {