diff --git a/src/equicordplugins/vcNarratorCustom/index.tsx b/src/equicordplugins/vcNarratorCustom/index.tsx index 8d0fef0c9..e1a340bf3 100644 --- a/src/equicordplugins/vcNarratorCustom/index.tsx +++ b/src/equicordplugins/vcNarratorCustom/index.tsx @@ -938,9 +938,19 @@ export default definePlugin({ flux: { async VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) { - const myGuildId = SelectedGuildStore.getGuildId(); - const myChanId = SelectedChannelStore.getVoiceChannelId(); const myId = UserStore.getCurrentUser().id; + const myGuildId = SelectedGuildStore.getGuildId(); + const myVoiceState = VoiceStateStore.getVoiceStateForUser(myId) as VoiceState | undefined; + let myChanId = myVoiceState?.channelId; + if (!myChanId) { + const selectedChanId = SelectedChannelStore.getVoiceChannelId(); + if (selectedChanId) { + const states = VoiceStateStore.getVoiceStatesForChannel?.(selectedChanId) as Record | undefined; + if (states?.[myId]?.channelId === selectedChanId) { + myChanId = selectedChanId; + } + } + } const filterMode = settings.store.stateChangeFilterMode ?? "off"; const filterList = parseStateChangeFilterList(settings.store.stateChangeFilterList); const allowStateChange = (targetId: string, isSelf: boolean) => { @@ -972,6 +982,7 @@ export default definePlugin({ let { oldChannelId } = state; const isMe = userId === myId; + if (!isMe && !myChanId) continue; if (isMe && channelId !== myLastChannelId) { oldChannelId = myLastChannelId; myLastChannelId = channelId ?? undefined; @@ -981,10 +992,12 @@ export default definePlugin({ if (!isMe && !affectsMyChannel) continue; // Keep snapshots in sync for join/leave/move without announcing state changes. - if (oldChannelId !== myChanId && channelId === myChanId) { - voiceStateSnapshot.set(userId, normalizeState(state)); - } else if (oldChannelId === myChanId && channelId !== myChanId) { - voiceStateSnapshot.delete(userId); + if (myChanId) { + if (oldChannelId !== myChanId && channelId === myChanId) { + voiceStateSnapshot.set(userId, normalizeState(state)); + } else if (oldChannelId === myChanId && channelId !== myChanId) { + voiceStateSnapshot.delete(userId); + } } // Join/leave/move announcements (existing behavior) @@ -1047,21 +1060,6 @@ export default definePlugin({ } }, - AUDIO_TOGGLE_SELF_MUTE() { - const chanId = SelectedChannelStore.getVoiceChannelId()!; - const s = VoiceStateStore.getVoiceStateForChannel( - chanId - ) as VoiceState; - if (!s) return; - }, - - AUDIO_TOGGLE_SELF_DEAF() { - const chanId = SelectedChannelStore.getVoiceChannelId()!; - const s = VoiceStateStore.getVoiceStateForChannel( - chanId - ) as VoiceState; - if (!s) return; - }, }, settingsAboutComponent({ tempSettings: s }: { tempSettings?: any; }) {