Skip to main content
Glama
jar285

MCP-Discord

by jar285

discord_delete_channel

Delete a Discord channel by providing its channel ID, with an optional reason for the deletion.

Instructions

Deletes a Discord channel with an optional reason

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
reasonNo

Implementation Reference

  • Handler function for discord_delete_channel tool. Parses arguments using DeleteChannelSchema, checks client readiness, fetches the channel, verifies deletability, deletes the channel using Discord.js API, and returns success or error response.
    case "discord_delete_channel": {
      const { channelId, reason } = DeleteChannelSchema.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 channel = await 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 {
          content: [{ type: "text", text: `Failed to delete channel: ${error}` }],
          isError: true
        };
      }
    }
  • Zod schema for input validation of discord_delete_channel tool, defining channelId as required string and reason as optional string.
    const DeleteChannelSchema = z.object({
        channelId: z.string(),
        reason: z.string().optional()
    });
  • src/index.ts:291-302 (registration)
    Tool registration in the listTools response, including name, description, and inputSchema matching DeleteChannelSchema.
    {
      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"]
      }
    },

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/jar285/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server