Added modal
This commit is contained in:
parent
872f87b22d
commit
ba57809c38
3 changed files with 75 additions and 5 deletions
39
RoleMembersModal.tsx
Normal file
39
RoleMembersModal.tsx
Normal file
|
@ -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 =>
|
||||||
|
<>
|
||||||
|
|
||||||
|
<ModalRoot {...props} size={ModalSize.DYNAMIC} fullscreenOnMobile={true}>
|
||||||
|
<ModalHeader className={cl("header")}>
|
||||||
|
<Forms.FormText style={{ fontSize: "1.2rem", fontWeight: "bold", marginRight: "7px" }}>Members of role {
|
||||||
|
Parser.parse(`<@&${roleId}>`, true, { channelId, viewingChannelId: channelId })
|
||||||
|
} ({members.length})</Forms.FormText>
|
||||||
|
<ModalCloseButton onClick={props.onClose} className={cl("close")} />
|
||||||
|
</ModalHeader>
|
||||||
|
<div style={{ padding: "13px 20px" }} className={cl("member-list")}>
|
||||||
|
{
|
||||||
|
members.length !== 0 ? members.map(member =>
|
||||||
|
<>
|
||||||
|
<Forms.FormText className={cl("modal-member")}>
|
||||||
|
{Parser.parse(`<@${member.userId}>`, true, { channelId, viewingChannelId: channelId })}
|
||||||
|
</Forms.FormText>
|
||||||
|
</>
|
||||||
|
) : <Forms.FormText>Looks like no online cached members with that role were found. Try scrolling down on your member list to cache more users!</Forms.FormText>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</ModalRoot>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
12
index.tsx
12
index.tsx
|
@ -4,12 +4,15 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "./style.css";
|
||||||
|
|
||||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessage } from "@api/Commands";
|
import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessage } from "@api/Commands";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Forms, GuildMemberStore, Parser } from "@webpack/common";
|
import { Forms, GuildMemberStore, Parser } from "@webpack/common";
|
||||||
|
import { GuildMember } from "discord-types/general";
|
||||||
|
|
||||||
import { showInRoleModal } from "./modal";
|
import { showInRoleModal } from "./RoleMembersModal";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "InRole",
|
name: "InRole",
|
||||||
|
@ -44,15 +47,14 @@ export default definePlugin({
|
||||||
return sendBotMessage(ctx.channel.id, { content: "Make sure that you are in a server." });
|
return sendBotMessage(ctx.channel.id, { content: "Make sure that you are in a server." });
|
||||||
}
|
}
|
||||||
const role = args[0].value;
|
const role = args[0].value;
|
||||||
console.log(role);
|
|
||||||
const members = GuildMemberStore.getMembers(ctx.guild!.id);
|
const members = GuildMemberStore.getMembers(ctx.guild!.id);
|
||||||
const membersInRole = [];
|
const membersInRole: GuildMember[] = [];
|
||||||
members.forEach(member => {
|
members.forEach(member => {
|
||||||
if (member.roles.includes(role)) {
|
if (member.roles.includes(role)) {
|
||||||
console.log(member);
|
membersInRole.push(member);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
showInRoleModal(membersInRole, role);
|
showInRoleModal(membersInRole, role, ctx.channel.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
29
style.css
Normal file
29
style.css
Normal file
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in a new issue