mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +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");
|
const SortedVoiceStateStore = findByPropsLazy("getVoiceStatesForChannel");
|
||||||
|
|
||||||
async function getVoiceChannelMentions(channel: Channel) {
|
function getVoiceChannelMentions(channel: Channel) {
|
||||||
return await SortedVoiceStateStore.getVoiceStatesForChannel(channel)
|
return SortedVoiceStateStore.getVoiceStatesForChannel(channel)
|
||||||
.filter((value: any) => value.user.id !== UserStore.getCurrentUser().id)
|
.filter((value: any) => value.user.id !== UserStore.getCurrentUser().id)
|
||||||
.map((value: any) => {
|
.map((value: any) => {
|
||||||
return `<@${value.user.id}>`;
|
return `<@${value.user.id}>`;
|
||||||
|
@ -22,18 +22,23 @@ async function getVoiceChannelMentions(channel: Channel) {
|
||||||
.join(" ");
|
.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isInVoiceChannel(channel: Channel) {
|
||||||
|
return SortedVoiceStateStore.getVoiceStatesForChannel(channel)
|
||||||
|
.some((value: any) => value.user.id == UserStore.getCurrentUser().id);
|
||||||
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "VoiceChatMention",
|
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],
|
authors: [Devs.nickwoah],
|
||||||
contextMenus: {
|
contextMenus: {
|
||||||
"channel-context"(children, { channel }: { channel: Channel; }) {
|
"channel-context"(children, { channel }: { channel: Channel; }) {
|
||||||
if (channel.isVocal()) children.push(
|
if (channel.isVocal() && isInVoiceChannel(channel)) children.push(
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="voice-mention-all-users"
|
id="voice-mention-all-users"
|
||||||
label="Mention All Users"
|
label="Mention All Users"
|
||||||
action={async () => {
|
action={async () => {
|
||||||
insertTextIntoChatInputBox(await getVoiceChannelMentions(channel));
|
insertTextIntoChatInputBox(getVoiceChannelMentions(channel));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue