2024-07-26 08:13:25 -04:00
|
|
|
/*
|
|
|
|
* Vencord, a Discord client mod
|
|
|
|
* Copyright (c) 2024 nin0dev
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
2024-07-26 12:14:12 -04:00
|
|
|
import "./style.css";
|
|
|
|
|
2024-07-26 09:46:04 -04:00
|
|
|
import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessage } from "@api/Commands";
|
2024-07-26 08:13:25 -04:00
|
|
|
import { Devs } from "@utils/constants";
|
|
|
|
import definePlugin from "@utils/types";
|
2024-07-26 09:46:04 -04:00
|
|
|
import { Forms, GuildMemberStore, Parser } from "@webpack/common";
|
2024-07-26 12:14:12 -04:00
|
|
|
import { GuildMember } from "discord-types/general";
|
2024-07-26 09:46:04 -04:00
|
|
|
|
2024-07-26 12:14:12 -04:00
|
|
|
import { showInRoleModal } from "./RoleMembersModal";
|
2024-07-26 08:13:25 -04:00
|
|
|
|
|
|
|
export default definePlugin({
|
|
|
|
name: "InRole",
|
2024-07-26 09:06:03 -04:00
|
|
|
description: "Know who is in a role (read plugin info!)",
|
2024-07-26 08:13:25 -04:00
|
|
|
authors: [Devs.nin0dev],
|
2024-07-26 09:06:03 -04:00
|
|
|
settingsAboutComponent: () => {
|
|
|
|
return (
|
|
|
|
<>
|
2024-07-26 09:46:04 -04:00
|
|
|
<Forms.FormText style={{ fontSize: "1.2rem", marginTop: "15px", fontWeight: "bold" }}>{Parser.parse(":warning:")} Limitations</Forms.FormText>
|
2024-07-26 09:06:03 -04:00
|
|
|
<Forms.FormText style={{ marginTop: "10px", fontWeight: "500" }} >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:</Forms.FormText>
|
2024-07-26 09:46:04 -04:00
|
|
|
<Forms.FormText>• Offline members won't be listed</Forms.FormText>
|
|
|
|
<Forms.FormText>• Up to 100 members will be listed by default. To get more, scroll down in the member list to load more members.</Forms.FormText>
|
2024-07-26 09:06:03 -04:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
commands: [
|
|
|
|
{
|
|
|
|
name: "inrole",
|
|
|
|
description: "Block someone",
|
|
|
|
inputType: ApplicationCommandInputType.BUILT_IN,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: "role",
|
|
|
|
description: "The role",
|
|
|
|
type: ApplicationCommandOptionType.ROLE,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
],
|
|
|
|
execute: (args, ctx) => {
|
2024-07-26 09:46:04 -04:00
|
|
|
// 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);
|
2024-07-26 12:14:12 -04:00
|
|
|
const membersInRole: GuildMember[] = [];
|
2024-07-26 09:46:04 -04:00
|
|
|
members.forEach(member => {
|
|
|
|
if (member.roles.includes(role)) {
|
2024-07-26 12:14:12 -04:00
|
|
|
membersInRole.push(member);
|
2024-07-26 09:46:04 -04:00
|
|
|
}
|
|
|
|
});
|
2024-07-26 12:14:12 -04:00
|
|
|
showInRoleModal(membersInRole, role, ctx.channel.id);
|
2024-07-26 09:06:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2024-07-26 08:13:25 -04:00
|
|
|
});
|