discord_create_forum_post
Create organized discussions in Discord forum channels by posting new topics with relevant tags to categorize conversations effectively.
Instructions
Creates a new post in a Discord forum channel with optional tags
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| forumChannelId | Yes | ||
| title | Yes | ||
| content | Yes | ||
| tags | No |
Implementation Reference
- src/index.ts:638-690 (handler)The handler function for discord_create_forum_post that parses arguments using CreateForumPostSchema, validates the forum channel, handles optional tags by matching names to IDs, creates the forum thread/post using discord.js, and returns success message with thread ID 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 defining the input parameters for discord_create_forum_post: forumChannelId (required string), title (required string), content (required string), tags (optional array of strings).const CreateForumPostSchema = z.object({ forumChannelId: z.string(), title: z.string(), content: z.string(), tags: z.array(z.string()).optional() });
- src/index.ts:238-254 (registration)Tool registration in the MCP server's tools list, specifying name, description, and JSON schema matching the Zod schema for input validation.{ 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"] } },