delete_thread
Remove Discord threads from servers by specifying guild and thread IDs. This tool helps manage server organization by deleting unnecessary or outdated 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 for the delete_thread tool. It fetches the Discord guild and thread, validates the thread exists, deletes it with an optional reason, handles errors using withErrorHandling, and returns a JSON-formatted success message or 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)Zod schema defining the input parameters for the delete_thread tool: required guildId and threadId, optional reason.{ 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)The server.tool call that registers the delete_thread tool with its name, description, input schema, and handler function within the registerThreadTools function.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:63-63 (registration)Invocation of registerThreadTools(server) in the createMcpServer function, which registers all thread management tools including delete_thread.registerThreadTools(server);