Skip to content

Commit

Permalink
Merge pull request #4 from D3SOX/fixVoiceChatUtilitiesChannelCheck
Browse files Browse the repository at this point in the history
fix(voiceChatUtilities): check channel type
  • Loading branch information
damsdev1 authored Feb 7, 2024
2 parents 7ebe9b0 + 79f4b6e commit 7f1724d
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/plugins/voiceChatUtilities/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
/*
* Vencord, a modification for Discord's desktop app
* Copyright (c) 2022 Vendicated and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
import { Devs } from "@utils/constants";
Expand Down Expand Up @@ -48,7 +36,11 @@ interface VoiceChannelContextProps {
}

const VoiceChannelContext: NavContextMenuPatchCallback = (children, { channel }: VoiceChannelContextProps) => () => {
if (!channel) return;
// only for voice and stage channels
if (!channel || (channel.type !== 2 && channel.type !== 13)) return;
const userCount = Object.keys(VoiceStateStore.getVoiceStatesForChannel(channel.id)).length;
if (userCount === 0) return;

const guildChannels: { VOCAL: { channel: Channel, comparator: number }[] } = GuildChannelStore.getChannels(channel.guild_id);
const voiceChannels = guildChannels.VOCAL.map(({ channel }) => channel).filter(({ id }) => id !== channel.id);

Expand Down

0 comments on commit 7f1724d

Please sign in to comment.