create_forum_post
Create a new post in a Discord forum channel by specifying server, channel, title, content, and optional tags or archive settings.
Instructions
Create a new post in a forum channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| channelId | Yes | The ID of the forum channel | |
| name | Yes | Title of the post | |
| content | Yes | Content of the initial message | |
| appliedTags | No | Tag IDs to apply | |
| autoArchiveDuration | No | Auto archive minutes | |
| reason | No | Reason for creating |
Implementation Reference
- src/tools/thread-tools.ts:136-176 (handler)The main handler function that implements the logic for creating a forum post by fetching the forum channel and calling threads.create with the provided title, content, tags, and other options.async ({ guildId, channelId, name, content, appliedTags, autoArchiveDuration, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!channel || channel.type !== ChannelType.GuildForum) { throw new Error('Channel is not a forum channel'); } const forumChannel = channel as ForumChannel; const archiveDurationMap: Record<string, ThreadAutoArchiveDuration> = { '60': ThreadAutoArchiveDuration.OneHour, '1440': ThreadAutoArchiveDuration.OneDay, '4320': ThreadAutoArchiveDuration.ThreeDays, '10080': ThreadAutoArchiveDuration.OneWeek, }; const thread = await forumChannel.threads.create({ name, message: { content }, appliedTags, autoArchiveDuration: autoArchiveDuration ? archiveDurationMap[autoArchiveDuration] : undefined, reason, }); return { id: thread.id, name: thread.name, parentId: thread.parentId, appliedTags: thread.appliedTags, message: 'Forum post created 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:127-135 (schema)Zod schema defining the input parameters for the create_forum_post tool.{ guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the forum channel'), name: z.string().describe('Title of the post'), content: z.string().describe('Content of the initial message'), appliedTags: z.array(z.string()).optional().describe('Tag IDs to apply'), autoArchiveDuration: z.enum(['60', '1440', '4320', '10080']).optional().describe('Auto archive minutes'), reason: z.string().optional().describe('Reason for creating'), },
- src/tools/thread-tools.ts:124-176 (registration)Registration of the create_forum_post tool via server.tool() call within registerThreadTools function.server.tool( 'create_forum_post', 'Create a new post in a forum channel', { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the forum channel'), name: z.string().describe('Title of the post'), content: z.string().describe('Content of the initial message'), appliedTags: z.array(z.string()).optional().describe('Tag IDs to apply'), autoArchiveDuration: z.enum(['60', '1440', '4320', '10080']).optional().describe('Auto archive minutes'), reason: z.string().optional().describe('Reason for creating'), }, async ({ guildId, channelId, name, content, appliedTags, autoArchiveDuration, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!channel || channel.type !== ChannelType.GuildForum) { throw new Error('Channel is not a forum channel'); } const forumChannel = channel as ForumChannel; const archiveDurationMap: Record<string, ThreadAutoArchiveDuration> = { '60': ThreadAutoArchiveDuration.OneHour, '1440': ThreadAutoArchiveDuration.OneDay, '4320': ThreadAutoArchiveDuration.ThreeDays, '10080': ThreadAutoArchiveDuration.OneWeek, }; const thread = await forumChannel.threads.create({ name, message: { content }, appliedTags, autoArchiveDuration: autoArchiveDuration ? archiveDurationMap[autoArchiveDuration] : undefined, reason, }); return { id: thread.id, name: thread.name, parentId: thread.parentId, appliedTags: thread.appliedTags, message: 'Forum post created 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 main server setup, which registers the create_forum_post tool among thread management tools.registerThreadTools(server);