discord_list_roles
Retrieve all roles in a Discord guild with their permissions and member counts to manage server structure and access controls.
Instructions
List all roles in a guild with permissions and member count.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guild_id | Yes |
Implementation Reference
- src/tools/roles.ts:120-132 (handler)The handler implementation for the discord_list_roles tool, which fetches the guild, retrieves roles, processes them, and returns them as a JSON string.
case "discord_list_roles": { const guild = await discord.guilds.fetch(validateId(args.guild_id, "guild_id")); const roles = await guild.roles.fetch(); const result = [...roles.values()] .filter((r) => r.name !== "@everyone") .sort((a, b) => b.position - a.position) .map((r) => ({ id: r.id, name: r.name, color: r.hexColor, position: r.position, memberCount: r.members.size, permissions: serializePermissions(r.permissions), hoist: r.hoist, mentionable: r.mentionable, })); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/tools/roles.ts:7-15 (schema)The definition and input schema for the discord_list_roles tool.
{ name: "discord_list_roles", description: "List all roles in a guild with permissions and member count.", inputSchema: { type: "object", properties: { guild_id: { type: "string" } }, required: ["guild_id"], }, },