edit_role
Modify Discord role settings including name, color, permissions, and display options to customize server member access and organization.
Instructions
Update the configuration of an existing role.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| role_id | Yes | ||
| server_id | No | ||
| name | No | ||
| color | No | ||
| colour | No | ||
| hoist | No | ||
| mentionable | No | ||
| permissions | No | ||
| permissions_value | No | ||
| position | No | ||
| unicode_emoji | No | ||
| reason | No |
Implementation Reference
- The main handler function that executes the edit_role tool. Fetches the guild and role, conditionally updates name, color (using hex_to_color helper), permissions (using parse_permissions helper), hoist, mentionable, and position properties, then edits the role via Discord API and returns a summary of changes.async def handle_edit_role(discord_client, arguments: Dict[str, Any]) -> List[TextContent]: """Edit an existing role""" guild = await discord_client.fetch_guild(int(arguments["server_id"])) role = guild.get_role(int(arguments["role_id"])) if not role: return [TextContent(type="text", text="Role not found")] edit_kwargs = {} changes_made = [] if "name" in arguments: edit_kwargs["name"] = arguments["name"] changes_made.append(f"Name: {arguments['name']}") if "color" in arguments: edit_kwargs["color"] = hex_to_color(arguments["color"]) changes_made.append(f"Color: {arguments['color']}") if "permissions" in arguments: edit_kwargs["permissions"] = parse_permissions(arguments["permissions"]) changes_made.append("Permissions updated") if "hoist" in arguments: edit_kwargs["hoist"] = arguments["hoist"] changes_made.append(f"Hoisted: {arguments['hoist']}") if "mentionable" in arguments: edit_kwargs["mentionable"] = arguments["mentionable"] changes_made.append(f"Mentionable: {arguments['mentionable']}") if "position" in arguments: edit_kwargs["position"] = arguments["position"] changes_made.append(f"Position: {arguments['position']}") edit_kwargs["reason"] = arguments.get("reason", "Role updated via MCP") if edit_kwargs: await role.edit(**edit_kwargs) return [TextContent( type="text", text=f"Updated role '{role.name}':\n• " + "\n• ".join(changes_made) )]
- Defines the input schema and description for the edit_role tool, including all parameters with types and requirements for validation.Tool( name="edit_role", description="Edit an existing role's properties and permissions", inputSchema={ "type": "object", "properties": { "server_id": {"type": "string", "description": "Server ID"}, "role_id": {"type": "string", "description": "Role ID"}, "name": {"type": "string", "description": "New role name"}, "color": {"type": "string", "description": "New role color (hex)"}, "permissions": {"type": "array", "items": {"type": "string"}, "description": "New permissions"}, "hoist": {"type": "boolean", "description": "Whether role is displayed separately"}, "mentionable": {"type": "boolean", "description": "Whether role is mentionable"}, "position": {"type": "number", "description": "New role position"}, "reason": {"type": "string", "description": "Reason for edit"} }, "required": ["server_id", "role_id"] } ),
- src/discord_mcp/integrated_server.py:1015-1019 (registration)Registers and dispatches the edit_role tool call to AdvancedToolHandlers.handle_edit_role by checking if the tool name is in advanced_tool_names list and dynamically calling the corresponding handler method.if name in advanced_tool_names: handler_method = f"handle_{name}" if hasattr(AdvancedToolHandlers, handler_method): return await getattr(AdvancedToolHandlers, handler_method)(discord_client, arguments)