mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-19 22:20:34 +00:00
Compare commits
12 commits
ffe1436e5b
...
371b29ca76
Author | SHA1 | Date | |
---|---|---|---|
|
371b29ca76 | ||
|
83341f6e3c | ||
|
8f6384a751 | ||
|
0113739d63 | ||
|
8fcfb9579a | ||
|
e8e1a7e6f9 | ||
|
da73fc17b4 | ||
|
1ae6c9c0dc | ||
|
dd957a2999 | ||
|
57b397e053 | ||
|
b3598e3a6a | ||
|
f4f2734806 |
2 changed files with 51 additions and 0 deletions
47
src/plugins/voiceChatMention/index.tsx
Normal file
47
src/plugins/voiceChatMention/index.tsx
Normal file
|
@ -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(
|
||||
<Menu.MenuItem
|
||||
id="voice-mention-all-users"
|
||||
label="Mention All Users"
|
||||
action={async () => {
|
||||
insertTextIntoChatInputBox(getVoiceChannelMentions(channel));
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -486,6 +486,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
name: "Oleh Polisan",
|
||||
id: 242305263313485825n
|
||||
},
|
||||
nickwoah: {
|
||||
name: "nickwoah",
|
||||
id: 644298972420374528n
|
||||
},
|
||||
HAHALOSAH: {
|
||||
name: "HAHALOSAH",
|
||||
id: 903418691268513883n
|
||||
|
|
Loading…
Reference in a new issue