Skip to main content
Glama

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
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
threadIdYesThe ID of the thread to delete
reasonNoReason for deleting

Implementation Reference

  • 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) }] }; }
  • 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'), },
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/scarecr0w12/discord-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server