discord_delete_forum_post
Delete a forum post or thread in Discord by providing its ID, with an optional reason for the deletion.
Instructions
Deletes a forum post or thread with an optional reason
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| threadId | Yes | ||
| reason | No |
Implementation Reference
- src/tools/forum.ts:225-263 (handler)The deleteForumPostHandler function that executes the 'discord_delete_forum_post' tool logic. It takes threadId and reason, fetches the thread via Discord API, verifies it's a thread, and deletes it.
export const deleteForumPostHandler: ToolHandler = async (args, { client }) => { const { threadId, reason } = DeleteForumPostSchema.parse(args); try { if (!client.isReady()) { return { content: [{ type: 'text', text: 'Discord client not logged in.' }], isError: true, }; } const thread = await client.channels.fetch(threadId); if (!thread?.isThread()) { return { content: [ { type: 'text', text: `Cannot find forum post/thread with ID: ${threadId}`, }, ], isError: true, }; } // Delete the forum post/thread await thread.delete(reason || 'Forum post deleted via API'); return { content: [ { type: 'text', text: `Successfully deleted forum post/thread with ID: ${threadId}`, }, ], }; } catch (error) { return handleDiscordError(error); } }; - src/schemas.ts:92-95 (schema)DeleteForumPostSchema - Zod schema validating threadId (string, required) and reason (string, optional). Used by the handler to parse and validate input arguments.
export const DeleteForumPostSchema = z.object({ threadId: z.string(), reason: z.string().optional(), }); - src/tool-list.ts:217-228 (registration)Tool registration entry in toolList array defining name 'discord_delete_forum_post', description, and inputSchema with threadId (required) and reason (optional).
{ name: 'discord_delete_forum_post', description: 'Deletes a forum post or thread with an optional reason', inputSchema: { type: 'object', properties: { threadId: { type: 'string' }, reason: { type: 'string' }, }, required: ['threadId'], }, }, - src/server.ts:133-136 (registration)Case handler in server.ts routing the 'discord_delete_forum_post' tool call to deleteForumPostHandler.
case 'discord_delete_forum_post': this.logClientState('before discord_delete_forum_post handler'); toolResponse = await deleteForumPostHandler(args, this.toolContext); return toolResponse; - src/tools/types.ts:14-17 (helper)ToolHandler type definition that the handler conforms to.
export type ToolHandler<T = any> = ( args: T, context: ToolContext ) => Promise<ToolResponse>;