diff --git a/src/plugins/voiceChatMention/index.tsx b/src/plugins/voiceChatMention/index.tsx new file mode 100644 index 000000000..50c8e6820 --- /dev/null +++ b/src/plugins/voiceChatMention/index.tsx @@ -0,0 +1,47 @@ +/* + * 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"); + +function getVoiceChannelMentions(channel: Channel) { + return SortedVoiceStateStore.getVoiceStatesForChannel(channel) + .filter((value: any) => value.user.id !== UserStore.getCurrentUser().id) + .map((value: any) => { + return `<@${value.user.id}>`; + }) + .join(" "); +} + +function isInVoiceChannel(channel: Channel) { + return SortedVoiceStateStore.getVoiceStatesForChannel(channel) + .some((value: any) => value.user.id == UserStore.getCurrentUser().id); +} + +export default definePlugin({ + name: "VoiceChatMention", + description: "Adds a context menu button to put mentions of all users in your voice chat in the text box.", + authors: [Devs.nickwoah], + contextMenus: { + "channel-context"(children, { channel }: { channel: Channel; }) { + if (channel.isVocal() && isInVoiceChannel(channel)) children.push( + { + insertTextIntoChatInputBox(getVoiceChannelMentions(channel)); + }} + /> + ); + } + } +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 0572fa102..a40f3e036 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -487,6 +487,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Oleh Polisan", id: 242305263313485825n }, + nickwoah: { + name: "nickwoah", + id: 644298972420374528n + }, HAHALOSAH: { name: "HAHALOSAH", id: 903418691268513883n