Skip to main content
Glama

create_channel

Add a new text, voice, category, announcement, forum, or stage channel to a Discord server by specifying its name, type, and server ID.

Instructions

Create a new channel in a Discord server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
nameYesName of the new channel
typeYesType of channel
parentIdNoID of the parent category
topicNoChannel topic (text channels only)
nsfwNoWhether the channel is NSFW
bitrateNoBitrate for voice channels
userLimitNoUser limit for voice channels
rateLimitPerUserNoSlowmode in seconds
positionNoPosition of the channel
reasonNoReason for creating the channel

Implementation Reference

  • The handler function for the create_channel tool. It fetches the Discord guild, constructs channel creation options based on input parameters (mapping type string to ChannelType enum), removes undefined options, creates the channel using guild.channels.create(), handles errors with withErrorHandling, and returns JSON-formatted response with new channel details.
    async ({ guildId, name, type, parentId, topic, nsfw, bitrate, userLimit, rateLimitPerUser, position, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channelOptions: Record<string, unknown> = { name, type: channelTypeMap[type], parent: parentId, topic, nsfw, bitrate, userLimit, rateLimitPerUser, position, reason, }; // Remove undefined values Object.keys(channelOptions).forEach((key) => { if (channelOptions[key] === undefined) delete channelOptions[key]; }); const newChannel = await guild.channels.create(channelOptions as any); return { id: newChannel.id, name: newChannel.name, type: ChannelType[newChannel.type], message: 'Channel created' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Zod input schema for create_channel tool, validating parameters like guildId, name, type (enum of channel types), and optional fields for customization.
    { guildId: z.string().describe('The ID of the server (guild)'), name: z.string().describe('Name of the new channel'), type: z.enum(['text', 'voice', 'category', 'announcement', 'forum', 'stage']).describe('Type of channel'), parentId: z.string().optional().describe('ID of the parent category'), topic: z.string().optional().describe('Channel topic (text channels only)'), nsfw: z.boolean().optional().describe('Whether the channel is NSFW'), bitrate: z.number().optional().describe('Bitrate for voice channels'), userLimit: z.number().optional().describe('User limit for voice channels'), rateLimitPerUser: z.number().optional().describe('Slowmode in seconds'), position: z.number().optional().describe('Position of the channel'), reason: z.string().optional().describe('Reason for creating the channel'), },
  • Full registration of the create_channel tool using server.tool(), including name, description, input schema, and inline handler function.
    server.tool( 'create_channel', 'Create a new channel in a Discord server', { guildId: z.string().describe('The ID of the server (guild)'), name: z.string().describe('Name of the new channel'), type: z.enum(['text', 'voice', 'category', 'announcement', 'forum', 'stage']).describe('Type of channel'), parentId: z.string().optional().describe('ID of the parent category'), topic: z.string().optional().describe('Channel topic (text channels only)'), nsfw: z.boolean().optional().describe('Whether the channel is NSFW'), bitrate: z.number().optional().describe('Bitrate for voice channels'), userLimit: z.number().optional().describe('User limit for voice channels'), rateLimitPerUser: z.number().optional().describe('Slowmode in seconds'), position: z.number().optional().describe('Position of the channel'), reason: z.string().optional().describe('Reason for creating the channel'), }, async ({ guildId, name, type, parentId, topic, nsfw, bitrate, userLimit, rateLimitPerUser, position, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channelOptions: Record<string, unknown> = { name, type: channelTypeMap[type], parent: parentId, topic, nsfw, bitrate, userLimit, rateLimitPerUser, position, reason, }; // Remove undefined values Object.keys(channelOptions).forEach((key) => { if (channelOptions[key] === undefined) delete channelOptions[key]; }); const newChannel = await guild.channels.create(channelOptions as any); return { id: newChannel.id, name: newChannel.name, type: ChannelType[newChannel.type], message: 'Channel created' }; }); 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:55-55 (registration)
    Top-level registration call to registerChannelTools(server), which includes the create_channel tool registration.
    registerChannelTools(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