Skip to main content
Glama

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
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the forum channel
nameYesTitle of the post
contentYesContent of the initial message
appliedTagsNoTag IDs to apply
autoArchiveDurationNoAuto archive minutes
reasonNoReason for creating

Implementation Reference

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

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