modify_member
Update Discord server member properties including nickname, roles, voice settings, timeout, and channel assignment using guild and member IDs.
Instructions
Modify member properties (nickname, roles, timeout, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| memberId | Yes | The ID of the member | |
| nickname | No | New nickname (null to remove) | |
| roles | No | Array of role IDs to set | |
| mute | No | Whether to mute in voice | |
| deaf | No | Whether to deafen in voice | |
| channelId | No | Voice channel ID to move to | |
| communicationDisabledUntil | No | ISO timestamp for timeout end | |
| reason | No | Reason for the modification |
Implementation Reference
- src/tools/member-tools.ts:112-143 (handler)Executes the modify_member tool: fetches guild and member, constructs update data from parameters (nickname, roles, mute, etc.), calls member.edit(), handles errors with withErrorHandling, returns JSON response.const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const member = await guild.members.fetch(memberId); const updateData: Record<string, unknown> = {}; if (nickname !== undefined) updateData.nick = nickname; if (roles !== undefined) updateData.roles = roles; if (mute !== undefined) updateData.mute = mute; if (deaf !== undefined) updateData.deaf = deaf; if (channelId !== undefined) updateData.channel = channelId; if (communicationDisabledUntil !== undefined) { updateData.communicationDisabledUntil = communicationDisabledUntil ? new Date(communicationDisabledUntil) : null; } if (reason !== undefined) updateData.reason = reason; const updatedMember = await member.edit(updateData); return { id: updatedMember.id, displayName: updatedMember.displayName, nickname: updatedMember.nickname, message: 'Member updated 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/tools/member-tools.ts:101-111 (schema)Zod schema defining input parameters for modify_member tool: guildId, memberId required; nickname, roles, mute, deaf, channelId, communicationDisabledUntil, reason optional.memberId: z.string().describe('The ID of the member'), nickname: z.string().optional().describe('New nickname (null to remove)'), roles: z.array(z.string()).optional().describe('Array of role IDs to set'), mute: z.boolean().optional().describe('Whether to mute in voice'), deaf: z.boolean().optional().describe('Whether to deafen in voice'), channelId: z.string().optional().describe('Voice channel ID to move to'), communicationDisabledUntil: z.string().optional().describe('ISO timestamp for timeout end'), reason: z.string().optional().describe('Reason for the modification'), }, async ({ guildId, memberId, nickname, roles, mute, deaf, channelId, communicationDisabledUntil, reason }) => { const result = await withErrorHandling(async () => {
- src/tools/member-tools.ts:98-144 (registration)Registers the 'modify_member' tool on the MCP server using server.tool(), including name, description, input schema, and handler function.'Modify member properties (nickname, roles, timeout, etc.)', { guildId: z.string().describe('The ID of the server (guild)'), memberId: z.string().describe('The ID of the member'), nickname: z.string().optional().describe('New nickname (null to remove)'), roles: z.array(z.string()).optional().describe('Array of role IDs to set'), mute: z.boolean().optional().describe('Whether to mute in voice'), deaf: z.boolean().optional().describe('Whether to deafen in voice'), channelId: z.string().optional().describe('Voice channel ID to move to'), communicationDisabledUntil: z.string().optional().describe('ISO timestamp for timeout end'), reason: z.string().optional().describe('Reason for the modification'), }, async ({ guildId, memberId, nickname, roles, mute, deaf, channelId, communicationDisabledUntil, 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 updateData: Record<string, unknown> = {}; if (nickname !== undefined) updateData.nick = nickname; if (roles !== undefined) updateData.roles = roles; if (mute !== undefined) updateData.mute = mute; if (deaf !== undefined) updateData.deaf = deaf; if (channelId !== undefined) updateData.channel = channelId; if (communicationDisabledUntil !== undefined) { updateData.communicationDisabledUntil = communicationDisabledUntil ? new Date(communicationDisabledUntil) : null; } if (reason !== undefined) updateData.reason = reason; const updatedMember = await member.edit(updateData); return { id: updatedMember.id, displayName: updatedMember.displayName, nickname: updatedMember.nickname, message: 'Member updated successfully', }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } ); // Kick a member
- src/index.ts:55-55 (registration)Top-level registration call that invokes registerMemberTools(server), which registers the modify_member tool among others.registerMemberTools(server);