add_thread_member
Add a user to a Discord thread by providing guild, thread, and user IDs to manage thread participation.
Instructions
Add a member to a thread
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| threadId | Yes | The ID of the thread | |
| userId | Yes | The ID of the user to add |
Implementation Reference
- src/tools/thread-tools.ts:343-363 (handler)Handler function that fetches the thread and adds the specified user as a member using thread.members.add(userId). Wraps in error handling and returns JSON response.async ({ guildId, threadId, userId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const thread = await guild.channels.fetch(threadId); if (!thread || !thread.isThread()) { throw new Error('Thread not found'); } await thread.members.add(userId); return { threadId, userId, message: 'Member added to thread' }; }); 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/thread-tools.ts:338-342 (schema)Zod input schema defining parameters: guildId, threadId, userId.{ guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread'), userId: z.string().describe('The ID of the user to add'), },
- src/tools/thread-tools.ts:336-364 (registration)Tool registration call using server.tool() with name 'add_thread_member', description, input schema, and handler function.'add_thread_member', 'Add a member to a thread', { guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread'), userId: z.string().describe('The ID of the user to add'), }, async ({ guildId, threadId, userId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const thread = await guild.channels.fetch(threadId); if (!thread || !thread.isThread()) { throw new Error('Thread not found'); } await thread.members.add(userId); return { threadId, userId, message: 'Member added to thread' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );