delete_channel
Remove a channel from a Discord server by specifying the server and channel IDs. Provide an optional reason for the deletion.
Instructions
Delete a channel from a Discord server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| channelId | Yes | The ID of the channel to delete | |
| reason | No | Reason for deleting the channel |
Implementation Reference
- src/tools/channel-tools.ts:182-199 (handler)The core handler function for the 'delete_channel' tool. It fetches the Discord guild and channel using the provided IDs, deletes the channel (optionally with a reason), and returns a success message with channel details or an error.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/tools/channel-tools.ts:177-181 (schema)Zod input schema defining the parameters for the 'delete_channel' tool: required guildId and channelId, optional reason.{ 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'), },
- src/index.ts:55-55 (registration)Top-level registration call in the main server setup that invokes registerChannelTools, which in turn registers the 'delete_channel' tool via server.tool().registerChannelTools(server);
- src/tools/channel-tools.ts:173-200 (registration)Direct registration of the 'delete_channel' tool using server.tool(), including name, description, schema, and handler within the registerChannelTools function.// Delete a channel 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) }] }; } );