mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-19 22:20:34 +00:00
Only show button when in VC
This commit is contained in:
parent
e8e1a7e6f9
commit
8fcfb9579a
1 changed files with 10 additions and 5 deletions
|
@ -13,8 +13,8 @@ import { Channel } from "discord-types/general";
|
|||
|
||||
const SortedVoiceStateStore = findByPropsLazy("getVoiceStatesForChannel");
|
||||
|
||||
async function getVoiceChannelMentions(channel: Channel) {
|
||||
return await SortedVoiceStateStore.getVoiceStatesForChannel(channel)
|
||||
function getVoiceChannelMentions(channel: Channel) {
|
||||
return SortedVoiceStateStore.getVoiceStatesForChannel(channel)
|
||||
.filter((value: any) => value.user.id !== UserStore.getCurrentUser().id)
|
||||
.map((value: any) => {
|
||||
return `<@${value.user.id}>`;
|
||||
|
@ -22,18 +22,23 @@ async function getVoiceChannelMentions(channel: Channel) {
|
|||
.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 a voice chat in the text box.",
|
||||
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()) children.push(
|
||||
if (channel.isVocal() && isInVoiceChannel(channel)) children.push(
|
||||
<Menu.MenuItem
|
||||
id="voice-mention-all-users"
|
||||
label="Mention All Users"
|
||||
action={async () => {
|
||||
insertTextIntoChatInputBox(await getVoiceChannelMentions(channel));
|
||||
insertTextIntoChatInputBox(getVoiceChannelMentions(channel));
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue