/*
* Vencord, a Discord client mod
* Copyright (c) 2024 nin0dev
* 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 "./RoleMembersModal";
export default definePlugin({
name: "InRole",
description: "Know who is in a role (read plugin info!)",
authors: [Devs.nin0dev],
settingsAboutComponent: () => {
return (
<>
{Parser.parse(":warning:")} Limitations
If you don't have mod permissions on the server, and that server is large (over 100 members), the plugin may be limited in the following ways:
• Offline members won't be listed
• Up to 100 members will be listed by default. To get more, scroll down in the member list to load more members.
>
);
},
commands: [
{
name: "inrole",
description: "Block someone",
inputType: ApplicationCommandInputType.BUILT_IN,
options: [
{
name: "role",
description: "The role",
type: ApplicationCommandOptionType.ROLE,
required: true
},
],
execute: (args, ctx) => {
// Guild check
if (!ctx.guild) {
return sendBotMessage(ctx.channel.id, { content: "Make sure that you are in a server." });
}
const role = args[0].value;
const members = GuildMemberStore.getMembers(ctx.guild!.id);
const membersInRole: GuildMember[] = [];
members.forEach(member => {
if (member.roles.includes(role)) {
membersInRole.push(member);
}
});
showInRoleModal(membersInRole, role, ctx.channel.id);
}
}
]
});