delete_thread
Remove a Discord thread from a server by specifying the guild and thread IDs. This tool helps manage server organization by deleting outdated or unnecessary discussion threads.
Instructions
Delete 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 to delete | |
| reason | No | Reason for deleting |
Implementation Reference
- src/tools/thread-tools.ts:248-269 (handler)The handler function that executes the delete_thread tool: fetches the guild and thread, deletes the thread with optional reason, handles errors with withErrorHandling, and returns success/error response.async ({ guildId, threadId, 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 threadName = thread.name; await thread.delete(reason); return { threadId, threadName, message: 'Thread deleted 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:243-247 (schema)Input schema using Zod for the delete_thread tool parameters.{ guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread to delete'), reason: z.string().optional().describe('Reason for deleting'), },
- src/tools/thread-tools.ts:240-270 (registration)Registration of the delete_thread tool on the MCP server using server.tool() including name, description, schema, and handler.server.tool( 'delete_thread', 'Delete a thread', { guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread to delete'), reason: z.string().optional().describe('Reason for deleting'), }, async ({ guildId, threadId, 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 threadName = thread.name; await thread.delete(reason); return { threadId, threadName, message: 'Thread deleted 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/index.ts:64-64 (registration)Higher-level registration call that includes the delete_thread tool via registerThreadTools.registerThreadTools(server);