diff --git a/src/equicordplugins/voiceChatUtils/index.tsx b/src/equicordplugins/voiceChatUtils/index.tsx index dd66f1260..64baf1ba5 100644 --- a/src/equicordplugins/voiceChatUtils/index.tsx +++ b/src/equicordplugins/voiceChatUtils/index.tsx @@ -7,6 +7,7 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; +import { insertTextIntoChatInputBox } from "@utils/discord"; import definePlugin, { makeRange, OptionType } from "@utils/types"; import type { Channel } from "@vencord/discord-types"; import { GuildChannelStore, Menu, React, RestAPI, UserStore, VoiceStateStore } from "@webpack/common"; @@ -48,6 +49,17 @@ function sendPatch(channel: Channel, body: Record, bypass = false) }); } +function mentionVoiceUsers(channel: Channel) { + const currentUserId = UserStore.getCurrentUser()?.id; + const mentions = Object.values(VoiceStateStore.getVoiceStatesForChannel(channel.id)) + .map(state => state.userId) + .filter((userId, index, arr) => userId && userId !== currentUserId && arr.indexOf(userId) === index) + .map(userId => `<@${userId}>`); + + if (mentions.length === 0) return; + insertTextIntoChatInputBox(`${mentions.join(" ")} `); +} + interface VoiceChannelContextProps { channel: Channel; } @@ -69,6 +81,13 @@ const VoiceChannelContext: NavContextMenuPatchCallback = (children, { channel }: key="voice-tools" id="voice-tools" > + mentionVoiceUsers(channel)} + /> + { await monacoWin.loadURL(`data:text/html;base64,${monacoHtml}`); }); -app.on("before-quit", async (event) => { +app.on("before-quit", async event => { if (monacoWin && !monacoWin.isDestroyed() && !monacoWin.isVisible()) { const result = await dialog.showMessageBox({ type: "question",