discord_create_forum_post
Create a new post in a Discord forum channel with a title, content, and optional tags for organized discussions. Ideal for AI assistants or users managing forums on MCP-Discord servers.
Instructions
Creates a new post in a Discord forum channel with optional tags
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| forumChannelId | Yes | ||
| tags | No | ||
| title | Yes |
Implementation Reference
- src/index.ts:638-690 (handler)The handler function that executes the discord_create_forum_post tool. It parses input using CreateForumPostSchema, fetches the forum channel, handles tags by matching names to IDs, creates the thread/post with Discord.js, and returns success or error.case "discord_create_forum_post": { const { forumChannelId, title, content, tags } = CreateForumPostSchema.parse(args); try { if (!client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in. Please use discord_login tool first." }], isError: true }; } const channel = await client.channels.fetch(forumChannelId); if (!channel || channel.type !== ChannelType.GuildForum) { return { content: [{ type: "text", text: `Channel ID ${forumChannelId} is not a forum channel.` }], isError: true }; } const forumChannel = channel as ForumChannel; // Get available tags in the forum const availableTags = forumChannel.availableTags; let selectedTagIds: string[] = []; // If tags are provided, find their IDs if (tags && tags.length > 0) { selectedTagIds = availableTags .filter(tag => tags.includes(tag.name)) .map(tag => tag.id); } // Create the forum post const thread = await forumChannel.threads.create({ name: title, message: { content: content }, appliedTags: selectedTagIds.length > 0 ? selectedTagIds : undefined }); return { content: [{ type: "text", text: `Successfully created forum post "${title}" with ID: ${thread.id}` }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to create forum post: ${error}` }], isError: true }; } }
- src/index.ts:152-157 (schema)Zod schema for input validation of the discord_create_forum_post tool, defining required fields forumChannelId, title, content, and optional tags array.const CreateForumPostSchema = z.object({ forumChannelId: z.string(), title: z.string(), content: z.string(), tags: z.array(z.string()).optional() });
- src/index.ts:239-254 (registration)MCP tool registration for discord_create_forum_post, including name, description, and inputSchema matching the Zod schema.name: "discord_create_forum_post", description: "Creates a new post in a Discord forum channel with optional tags", inputSchema: { type: "object", properties: { forumChannelId: { type: "string" }, title: { type: "string" }, content: { type: "string" }, tags: { type: "array", items: { type: "string" } } }, required: ["forumChannelId", "title", "content"] } },