discord_create_text_channel
Create a new text channel in a Discord server, specifying the channel name and optional topic, to organize conversations effectively.
Instructions
Creates a new text channel in a Discord server with an optional topic
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channelName | Yes | ||
| guildId | Yes | ||
| topic | No |
Implementation Reference
- src/tools/channel.ts:109-148 (handler)The main handler function that parses arguments using CreateTextChannelSchema and creates a new Discord text channel using guild.channels.create with optional topic and reason.export async function createTextChannelHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { guildId, channelName, topic, reason } = CreateTextChannelSchema.parse(args); try { if (!context.client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in." }], isError: true }; } const guild = await context.client.guilds.fetch(guildId); if (!guild) { return { content: [{ type: "text", text: `Cannot find guild with ID: ${guildId}` }], isError: true }; } // Create the text channel const channelOptions: any = { name: channelName, type: ChannelType.GuildText }; if (topic) channelOptions.topic = topic; if (reason) channelOptions.reason = reason; const channel = await guild.channels.create(channelOptions); return { content: [{ type: "text", text: `Successfully created text channel "${channelName}" with ID: ${channel.id}` }] }; } catch (error) { return handleDiscordError(error); } }
- src/toolList.ts:117-129 (schema)MCP tool schema definition including name, description, and input schema for discord_create_text_channel.{ name: "discord_create_text_channel", description: "Creates a new text channel in a Discord server with an optional topic", inputSchema: { type: "object", properties: { guildId: { type: "string" }, channelName: { type: "string" }, topic: { type: "string" } }, required: ["guildId", "channelName"] } },
- src/server.ts:123-126 (registration)Switch case registration in the main server handler that dispatches to createTextChannelHandler.case "discord_create_text_channel": this.logClientState("before discord_create_text_channel handler"); toolResponse = await createTextChannelHandler(args, this.toolContext); return toolResponse;
- src/schemas.ts:33-38 (schema)Zod validation schema used by the handler to parse input arguments.export const CreateTextChannelSchema = z.object({ guildId: z.string(), channelName: z.string(), topic: z.string().optional(), reason: z.string().optional() });