Access role members even when offline (up to 100), switch from members list, context menu from server #1
2 changed files with 44 additions and 9 deletions
17
icons.tsx
Normal file
17
icons.tsx
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
export function MemberIcon() {
|
||||
return (
|
||||
<svg
|
||||
height="20"
|
||||
width="20"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path fill="currentColor" d="M14.5 8a3 3 0 1 0-2.7-4.3c-.2.4.06.86.44 1.12a5 5 0 0 1 2.14 3.08c.01.06.06.1.12.1ZM18.44 17.27c.15.43.54.73 1 .73h1.06c.83 0 1.5-.67 1.5-1.5a7.5 7.5 0 0 0-6.5-7.43c-.55-.08-.99.38-1.1.92-.06.3-.15.6-.26.87-.23.58-.05 1.3.47 1.63a9.53 9.53 0 0 1 3.83 4.78ZM12.5 9a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM2 20.5a7.5 7.5 0 0 1 15 0c0 .83-.67 1.5-1.5 1.5a.2.2 0 0 1-.2-.16c-.2-.96-.56-1.87-.88-2.54-.1-.23-.42-.15-.42.1v2.1a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-2.1c0-.25-.31-.33-.42-.1-.32.67-.67 1.58-.88 2.54a.2.2 0 0 1-.2.16A1.5 1.5 0 0 1 2 20.5Z" />
|
||||
</svg>
|
||||
);
|
||||
}
|
36
index.tsx
36
index.tsx
|
@ -7,14 +7,15 @@
|
|||
import "./style.css";
|
||||
|
||||
import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessage } from "@api/Commands";
|
||||
import { findGroupChildrenByChildId } from "@api/ContextMenu";
|
||||
import { getUserSettingLazy } from "@api/UserSettings";
|
||||
import { InfoIcon } from "@components/Icons";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getCurrentChannel, getCurrentGuild } from "@utils/discord";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Forms, GuildMemberStore, GuildStore, Menu, Parser } from "@webpack/common";
|
||||
import { GuildMember } from "discord-types/general";
|
||||
import { Guild, GuildMember } from "discord-types/general";
|
||||
|
||||
import { MemberIcon } from "./icons";
|
||||
import { showInRoleModal } from "./RoleMembersModal";
|
||||
|
||||
const DeveloperMode = getUserSettingLazy("appearance", "developerMode")!;
|
||||
|
@ -33,7 +34,13 @@ function getMembersInRole(roleId: string, guildId: string) {
|
|||
export default definePlugin({
|
||||
name: "InRole",
|
||||
description: "Know who is in a role with the role context menu or /inrole command (read plugin info!)",
|
||||
authors: [Devs.nin0dev],
|
||||
authors: [
|
||||
Devs.nin0dev,
|
||||
{
|
||||
name: "Ryfter",
|
||||
id: 898619112350183445n,
|
||||
},
|
||||
],
|
||||
dependencies: ["UserSettingsAPI"],
|
||||
start() {
|
||||
// DeveloperMode needs to be enabled for the context menu to be shown
|
||||
|
@ -44,9 +51,8 @@ export default definePlugin({
|
|||
<>
|
||||
<Forms.FormText style={{ fontSize: "1.2rem", marginTop: "15px", fontWeight: "bold" }}>{Parser.parse(":warning:")} Limitations</Forms.FormText>
|
||||
<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>
|
||||
<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>
|
||||
<Forms.FormText>• However, friends will always be shown regardless of their status.</Forms.FormText>
|
||||
<Forms.FormText>• Up to 100 members will be listed by default for each role. To get more, scroll down in the member list to cache more members.</Forms.FormText>
|
||||
<Forms.FormText>• However, friends will always be shown.</Forms.FormText>
|
||||
</>
|
||||
);
|
||||
},
|
||||
|
@ -70,7 +76,7 @@ export default definePlugin({
|
|||
return sendBotMessage(ctx.channel.id, { content: "Make sure that you are in a server." });
|
||||
}
|
||||
const role = args[0].value;
|
||||
showInRoleModal(getMembersInRole(role, ctx.guild.id), role, ctx.channel.id);
|
||||
showInRoleModal(ctx.guild.id, role);
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -90,9 +96,21 @@ export default definePlugin({
|
|||
id="vc-view-inrole"
|
||||
label="View Members in Role"
|
||||
action={() => {
|
||||
showInRoleModal(getMembersInRole(role.id, guild.id), role.id, channel.id);
|
||||
showInRoleModal(guild.id, role.id);
|
||||
}}
|
||||
icon={InfoIcon}
|
||||
icon={MemberIcon}
|
||||
/>
|
||||
);
|
||||
},
|
||||
"guild-header-popout"(children, { guild }: { guild: Guild, onClose(): void; }) {
|
||||
if (!guild) return;
|
||||
const group = findGroupChildrenByChildId("privacy", children);
|
||||
group?.push(
|
||||
<Menu.MenuItem
|
||||
label="View members in role"
|
||||
id="inrole-menuitem"
|
||||
icon={MemberIcon}
|
||||
action={() => showInRoleModal(guild.id, "0")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue