discord_add_role
Assign a role to a Discord member by providing guild, user, and role IDs. This tool manages user permissions and access within Discord servers.
Instructions
Assign a role to a member.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guild_id | Yes | ||
| user_id | Yes | ||
| role_id | Yes | ||
| reason | No |
Implementation Reference
- src/tools/roles.ts:172-177 (handler)The handler logic for 'discord_add_role', which fetches the guild and member, then adds the specified role.
case "discord_add_role": { const guild = await discord.guilds.fetch(validateId(args.guild_id, "guild_id")); const member = await guild.members.fetch(args.user_id as string); await member.roles.add(args.role_id as string, args.reason as string | undefined); return { content: [{ type: "text", text: `✅ Role added to ${member.user.tag}.` }] }; } - src/tools/roles.ts:62-75 (schema)The tool definition and input schema for 'discord_add_role'.
{ name: "discord_add_role", description: "Assign a role to a member.", inputSchema: { type: "object", properties: { guild_id: { type: "string" }, user_id: { type: "string" }, role_id: { type: "string" }, reason: { type: "string" }, }, required: ["guild_id", "user_id", "role_id"], }, },