Skip to main content
Glama

remove_role

Remove a Discord role from a server member by specifying guild, member, and role IDs. Use this tool to manage user permissions and roles in Discord servers.

Instructions

Remove a role from a member

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
memberIdYesThe ID of the member
roleIdYesThe ID of the role to remove
reasonNoReason for removing the role

Implementation Reference

  • Full implementation of the 'remove_role' tool, including schema, handler logic to remove role from member using Discord.js API, and error handling.
    server.tool( 'remove_role', 'Remove a role from a member', { guildId: z.string().describe('The ID of the server (guild)'), memberId: z.string().describe('The ID of the member'), roleId: z.string().describe('The ID of the role to remove'), reason: z.string().optional().describe('Reason for removing the role'), }, async ({ guildId, memberId, roleId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const member = await guild.members.fetch(memberId); const role = await guild.roles.fetch(roleId); if (!role) throw new Error('Role not found'); await member.roles.remove(role, reason); return { memberId, roleId, roleName: role.name, memberName: member.displayName, message: 'Role removed successfully', }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/scarecr0w12/discord-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server