delete_role
Remove a role from a Discord server by specifying the server and role IDs to manage server permissions and organization.
Instructions
Delete a role from a Discord server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| roleId | Yes | The ID of the role to delete | |
| reason | No | Reason for deleting the role |
Implementation Reference
- src/tools/role-tools.ts:130-156 (handler)The complete server.tool registration for 'delete_role', including schema validation and the handler function that fetches the guild and role using Discord.js and executes role.delete(reason). This is the exact implementation of the tool.server.tool( 'delete_role', 'Delete a role from a Discord server', { guildId: z.string().describe('The ID of the server (guild)'), roleId: z.string().describe('The ID of the role to delete'), reason: z.string().optional().describe('Reason for deleting the role'), }, async ({ guildId, roleId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const role = await guild.roles.fetch(roleId); if (!role) throw new Error('Role not found'); const roleName = role.name; await role.delete(reason); return { roleId, roleName, message: 'Role deleted successfully' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
- src/index.ts:57-57 (registration)Registration call for the role-tools module in the main MCP server setup, which includes the delete_role tool.registerRoleTools(server);
- src/tools/role-tools.ts:133-137 (schema)Zod schema defining input parameters for the delete_role tool: required guildId and roleId, optional reason.{ guildId: z.string().describe('The ID of the server (guild)'), roleId: z.string().describe('The ID of the role to delete'), reason: z.string().optional().describe('Reason for deleting the role'), },