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:
1 parent
c9ad75b512
commit
1367a2257f
1 file changed
+11
-4
@@ -96,8 +96,13 @@ export function scanExistingStreamers(channel: VoiceChannel): void {
|
|||||||
if (!members || members.size === 0) return;
|
if (!members || members.size === 0) return;
|
||||||
let watched = 0;
|
let watched = 0;
|
||||||
for (const [, member] of members) {
|
for (const [, member] of members) {
|
||||||
const vs = member.voice?.streaming;
|
// Watch anyone with video ACTIVE: screen share (streaming) OR camera
|
||||||
if (vs && member.id !== _client?.user?.id) {
|
// (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);
|
startVideoRecording(channel, member.id);
|
||||||
watched++;
|
watched++;
|
||||||
}
|
}
|
||||||
@@ -129,11 +134,13 @@ async function handleVoiceStateUpdate(
|
|||||||
if (!channel) return; // not an actively-recorded channel
|
if (!channel) return; // not an actively-recorded channel
|
||||||
|
|
||||||
const streaming = Boolean(newState.streaming);
|
const streaming = Boolean(newState.streaming);
|
||||||
|
const cameraOn = Boolean(newState.selfVideo);
|
||||||
|
const hasVideo = streaming || cameraOn;
|
||||||
const inChannel = newState.channelId === channel.id;
|
const inChannel = newState.channelId === channel.id;
|
||||||
|
|
||||||
if (streaming && inChannel) {
|
if (hasVideo && inChannel) {
|
||||||
startVideoRecording(channel, newState.id);
|
startVideoRecording(channel, newState.id);
|
||||||
} else if (!inChannel || !streaming) {
|
} else if (!inChannel || !hasVideo) {
|
||||||
stopVideoRecording(channel.guild.id, newState.id);
|
stopVideoRecording(channel.guild.id, newState.id);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in new issue
Block a user