modify_thread
Update Discord thread settings including name, archive status, lock state, slowmode, auto-archive duration, and tags to manage server conversations.
Instructions
Modify 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 | |
| name | No | New name | |
| archived | No | Archive/unarchive the thread | |
| locked | No | Lock/unlock the thread | |
| autoArchiveDuration | No | Auto archive minutes | |
| rateLimitPerUser | No | Slowmode in seconds (0-21600) | |
| appliedTags | No | Applied tags (forum posts only) | |
| reason | No | Reason for modifying |
Implementation Reference
- src/tools/thread-tools.ts:194-236 (handler)The handler function that fetches the Discord thread and edits it with the provided parameters (name, archived, locked, autoArchiveDuration, rateLimitPerUser, appliedTags, reason) using thread.edit() and returns the updated thread info or error.async ({ guildId, threadId, name, archived, locked, autoArchiveDuration, rateLimitPerUser, appliedTags, reason }) => { 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'); } const archiveDurationMap: Record<string, ThreadAutoArchiveDuration> = { '60': ThreadAutoArchiveDuration.OneHour, '1440': ThreadAutoArchiveDuration.OneDay, '4320': ThreadAutoArchiveDuration.ThreeDays, '10080': ThreadAutoArchiveDuration.OneWeek, }; const editData: Record<string, unknown> = {}; if (name !== undefined) editData.name = name; if (archived !== undefined) editData.archived = archived; if (locked !== undefined) editData.locked = locked; if (autoArchiveDuration) editData.autoArchiveDuration = archiveDurationMap[autoArchiveDuration]; if (rateLimitPerUser !== undefined) editData.rateLimitPerUser = rateLimitPerUser; if (appliedTags) editData.appliedTags = appliedTags; if (reason) editData.reason = reason; const updated = await thread.edit(editData); return { id: updated.id, name: updated.name, archived: updated.archived, locked: updated.locked, message: 'Thread 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/thread-tools.ts:184-193 (schema)Zod input schema defining parameters for modifying a thread: guildId, threadId (required), and optional fields for name, archived status, locked status, auto-archive duration, rate limit, tags, and reason.guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread'), name: z.string().optional().describe('New name'), archived: z.boolean().optional().describe('Archive/unarchive the thread'), locked: z.boolean().optional().describe('Lock/unlock the thread'), autoArchiveDuration: z.enum(['60', '1440', '4320', '10080']).optional().describe('Auto archive minutes'), rateLimitPerUser: z.number().optional().describe('Slowmode in seconds (0-21600)'), appliedTags: z.array(z.string()).optional().describe('Applied tags (forum posts only)'), reason: z.string().optional().describe('Reason for modifying'), },
- src/tools/thread-tools.ts:180-237 (registration)Registers the 'modify_thread' tool on the MCP server using server.tool(), providing name, description, input schema, and handler function.server.tool( 'modify_thread', 'Modify a thread', { guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread'), name: z.string().optional().describe('New name'), archived: z.boolean().optional().describe('Archive/unarchive the thread'), locked: z.boolean().optional().describe('Lock/unlock the thread'), autoArchiveDuration: z.enum(['60', '1440', '4320', '10080']).optional().describe('Auto archive minutes'), rateLimitPerUser: z.number().optional().describe('Slowmode in seconds (0-21600)'), appliedTags: z.array(z.string()).optional().describe('Applied tags (forum posts only)'), reason: z.string().optional().describe('Reason for modifying'), }, async ({ guildId, threadId, name, archived, locked, autoArchiveDuration, rateLimitPerUser, appliedTags, reason }) => { 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'); } const archiveDurationMap: Record<string, ThreadAutoArchiveDuration> = { '60': ThreadAutoArchiveDuration.OneHour, '1440': ThreadAutoArchiveDuration.OneDay, '4320': ThreadAutoArchiveDuration.ThreeDays, '10080': ThreadAutoArchiveDuration.OneWeek, }; const editData: Record<string, unknown> = {}; if (name !== undefined) editData.name = name; if (archived !== undefined) editData.archived = archived; if (locked !== undefined) editData.locked = locked; if (autoArchiveDuration) editData.autoArchiveDuration = archiveDurationMap[autoArchiveDuration]; if (rateLimitPerUser !== undefined) editData.rateLimitPerUser = rateLimitPerUser; if (appliedTags) editData.appliedTags = appliedTags; if (reason) editData.reason = reason; const updated = await thread.edit(editData); return { id: updated.id, name: updated.name, archived: updated.archived, locked: updated.locked, message: 'Thread 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) }] }; } );