discord_delete_channel
Remove a Discord channel using its channel ID and optionally specify a reason. This tool is part of the MCP-Discord server, which facilitates AI-driven Discord management tasks.
Instructions
Deletes a Discord channel with an optional reason
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channelId | Yes | ||
| reason | No |
Input Schema (JSON Schema)
{
"properties": {
"channelId": {
"type": "string"
},
"reason": {
"type": "string"
}
},
"required": [
"channelId"
],
"type": "object"
}
Implementation Reference
- src/tools/channel.ts:151-192 (handler)The main handler function that parses arguments using DeleteChannelSchema, fetches the Discord channel, validates it supports deletion, and deletes it using channel.delete(). Handles errors and client readiness.export async function deleteChannelHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { channelId, reason } = DeleteChannelSchema.parse(args); try { if (!context.client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in." }], isError: true }; } const channel = await context.client.channels.fetch(channelId); if (!channel) { return { content: [{ type: "text", text: `Cannot find channel with ID: ${channelId}` }], isError: true }; } // Check if channel can be deleted (has delete method) if (!('delete' in channel)) { return { content: [{ type: "text", text: `This channel type does not support deletion or the bot lacks permissions` }], isError: true }; } // Delete the channel await channel.delete(reason || "Channel deleted via API"); return { content: [{ type: "text", text: `Successfully deleted channel with ID: ${channelId}` }] }; } catch (error) { return handleDiscordError(error); } }
- src/schemas.ts:60-63 (schema)Zod schema used for input validation in the deleteChannelHandler, defining channelId as required string and reason as optional string.export const DeleteChannelSchema = z.object({ channelId: z.string(), reason: z.string().optional() });
- src/toolList.ts:130-141 (schema)MCP tool definition including name, description, and JSON inputSchema advertised via ListTools.{ name: "discord_delete_channel", description: "Deletes a Discord channel with an optional reason", inputSchema: { type: "object", properties: { channelId: { type: "string" }, reason: { type: "string" } }, required: ["channelId"] } },
- src/server.ts:128-131 (registration)Switch case in CallToolRequest handler that dispatches to deleteChannelHandler for the "discord_delete_channel" tool.case "discord_delete_channel": this.logClientState("before discord_delete_channel handler"); toolResponse = await deleteChannelHandler(args, this.toolContext); return toolResponse;