From f4f27348067b070676d66188133d42600f97ca61 Mon Sep 17 00:00:00 2001 From: Nick <29809309+PrinceBunBun981@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:50:20 -0400 Subject: [PATCH] Voice Chat Mention --- src/plugins/voiceChannelMention/index.tsx | 37 +++++++++++++++++++++++ src/utils/constants.ts | 4 +++ 2 files changed, 41 insertions(+) create mode 100644 src/plugins/voiceChannelMention/index.tsx diff --git a/src/plugins/voiceChannelMention/index.tsx b/src/plugins/voiceChannelMention/index.tsx new file mode 100644 index 000000000..024fb13d0 --- /dev/null +++ b/src/plugins/voiceChannelMention/index.tsx @@ -0,0 +1,37 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated, nickwoah, and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Devs } from "@utils/constants"; +import { insertTextIntoChatInputBox } from "@utils/discord"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; +import { Menu, UserStore } from "@webpack/common"; +import { Channel } from "discord-types/general"; + +const SortedVoiceStateStore = findByPropsLazy("getVoiceStatesForChannel"); + +async function getVoiceChannelMentions(channel: Channel) { + return await SortedVoiceStateStore.getVoiceStatesForChannel(channel).filter((value: any) => value.user.id !== UserStore.getCurrentUser().id).map((value: any) => { return `<@${value.user.id}>`; }).join(" "); +} + +export default definePlugin({ + name: "VoiceChatMention", + description: "Adds a context menu button to put mentions of all users in a voice chat in the text box.", + authors: [Devs.nickwoah], + contextMenus: { + "channel-context"(children, { channel }: { channel: Channel; }) { + if (channel.isVocal()) children.push( + { + insertTextIntoChatInputBox(await getVoiceChannelMentions(channel)); + }} + /> + ); + } + } +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index f3626aaa0..12622ae53 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -425,6 +425,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ newwares: { name: "newwares", id: 421405303951851520n + }, + nickwoah: { + name: "nickwoah", + id: 644298972420374528n } } satisfies Record);