Skip to main content
Glama

delete_channel

Remove a channel from a Discord server by specifying the server and channel IDs. This tool helps manage server structure by deleting unnecessary or outdated channels.

Instructions

Delete a channel from a Discord server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel to delete
reasonNoReason for deleting the channel

Implementation Reference

  • The handler function that fetches the Discord guild and channel, then deletes the channel using channel.delete(reason), wrapped in error handling with withErrorHandling.
    async ({ guildId, channelId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!channel) throw new Error('Channel not found'); const channelName = channel.name; await channel.delete(reason); return { channelId, channelName, message: 'Channel deleted successfully' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Zod schema defining input parameters: guildId (required string), channelId (required string), reason (optional string).
    { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel to delete'), reason: z.string().optional().describe('Reason for deleting the channel'), },
  • MCP tool registration call to server.tool with name 'delete_channel', description, input schema, and handler function.
    server.tool( 'delete_channel', 'Delete a channel from a Discord server', { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel to delete'), reason: z.string().optional().describe('Reason for deleting the channel'), }, async ({ guildId, channelId, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!channel) throw new Error('Channel not found'); const channelName = channel.name; await channel.delete(reason); return { channelId, channelName, message: 'Channel deleted successfully' }; }); 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:54-54 (registration)
    Invocation of registerChannelTools which registers the delete_channel tool among others.
    registerChannelTools(server);
  • src/index.ts:12-12 (registration)
    Import of the registerChannelTools function that contains the delete_channel tool registration.
    import { registerChannelTools } from './tools/channel-tools.js';

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