discord_get_forum_channels
Retrieve a list of all forum channels within a specified Discord server (guild) using this tool, enabling efficient management and organization of discussions.
Instructions
Lists all forum channels in a specified Discord server (guild)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes |
Implementation Reference
- src/index.ts:81-83 (schema)Zod schema for input validation of discord_get_forum_channels tool, requiring guildId string.const GetForumChannelsSchema = z.object({ guildId: z.string() });
- src/index.ts:227-237 (registration)Tool registration in ListToolsRequestHandler, defining name, description, and inputSchema matching the schema.{ name: "discord_get_forum_channels", description: "Lists all forum channels in a specified Discord server (guild)", inputSchema: { type: "object", properties: { guildId: { type: "string" } }, required: ["guildId"] } },
- src/index.ts:590-636 (handler)Handler function in CallToolRequestHandler switch case that fetches guild, filters forum channels (ChannelType.GuildForum), formats id/name/topic, returns JSON.case "discord_get_forum_channels": { const { guildId } = GetForumChannelsSchema.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 guild = await client.guilds.fetch(guildId); if (!guild) { return { content: [{ type: "text", text: `Cannot find guild with ID: ${guildId}` }], isError: true }; } // Fetch all channels from the guild const channels = await guild.channels.fetch(); // Filter to get only forum channels const forumChannels = channels.filter(channel => channel?.type === ChannelType.GuildForum); if (forumChannels.size === 0) { return { content: [{ type: "text", text: `No forum channels found in guild: ${guild.name}` }] }; } // Format forum channels information const forumInfo = forumChannels.map(channel => ({ id: channel.id, name: channel.name, topic: channel.topic || "No topic set" })); return { content: [{ type: "text", text: JSON.stringify(forumInfo, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to fetch forum channels: ${error}` }], isError: true }; } }