From ba57809c3897be339957251b09b1a9c16dd9393a Mon Sep 17 00:00:00 2001 From: nin0dev Date: Fri, 26 Jul 2024 12:14:12 -0400 Subject: [PATCH] Added modal --- RoleMembersModal.tsx | 39 +++++++++++++++++++++++++++++++++++++++ index.tsx | 12 +++++++----- style.css | 29 +++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 RoleMembersModal.tsx create mode 100644 style.css diff --git a/RoleMembersModal.tsx b/RoleMembersModal.tsx new file mode 100644 index 0000000..da8d950 --- /dev/null +++ b/RoleMembersModal.tsx @@ -0,0 +1,39 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { classNameFactory } from "@api/Styles"; +import { ModalCloseButton, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; +import { Forms, Parser } from "@webpack/common"; +import { GuildMember } from "discord-types/general"; + +const cl = classNameFactory("vc-inrole-"); + +export function showInRoleModal(members: GuildMember[], roleId: string, channelId: string) { + openModal(props => + <> + + + + Members of role { + Parser.parse(`<@&${roleId}>`, true, { channelId, viewingChannelId: channelId }) + } ({members.length}) + + +
+ { + members.length !== 0 ? members.map(member => + <> + + {Parser.parse(`<@${member.userId}>`, true, { channelId, viewingChannelId: channelId })} + + + ) : Looks like no online cached members with that role were found. Try scrolling down on your member list to cache more users! + } +
+
+ + ); +} diff --git a/index.tsx b/index.tsx index 41062d2..c229aa9 100644 --- a/index.tsx +++ b/index.tsx @@ -4,12 +4,15 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import "./style.css"; + import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessage } from "@api/Commands"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Forms, GuildMemberStore, Parser } from "@webpack/common"; +import { GuildMember } from "discord-types/general"; -import { showInRoleModal } from "./modal"; +import { showInRoleModal } from "./RoleMembersModal"; export default definePlugin({ name: "InRole", @@ -44,15 +47,14 @@ export default definePlugin({ return sendBotMessage(ctx.channel.id, { content: "Make sure that you are in a server." }); } const role = args[0].value; - console.log(role); const members = GuildMemberStore.getMembers(ctx.guild!.id); - const membersInRole = []; + const membersInRole: GuildMember[] = []; members.forEach(member => { if (member.roles.includes(role)) { - console.log(member); + membersInRole.push(member); } }); - showInRoleModal(membersInRole, role); + showInRoleModal(membersInRole, role, ctx.channel.id); } } ] diff --git a/style.css b/style.css new file mode 100644 index 0000000..b3184ea --- /dev/null +++ b/style.css @@ -0,0 +1,29 @@ +.vc-inrole-member-list { + max-height: 400px; + margin-top: 10px; + margin-bottom: 13px; + overflow-x: hidden; +} + +.vc-inrole-member-list::-webkit-scrollbar { + background-color: #fff1; + border-radius: 100px; + width: 10px; +} + +.vc-inrole-member-list::-webkit-scrollbar-thumb { + background-color: #fff3; + border-radius: 100px; +} + +.vc-inrole-modal-member { + margin: 11px 0; +} + +.vc-inrole-header { + padding-top: "15px"; +} + +.vc-inrole-close { + margin-left: auto; +}