Skip to main content
Glama

delete_channel_permission

Remove permission overwrites for roles or members on Discord channels to manage access control and channel security settings.

Instructions

Delete a permission overwrite for a role or member on a channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel
targetIdYesThe ID of the role or member
reasonNoReason for the deletion

Implementation Reference

  • The handler function that executes the tool: fetches guild and channel, deletes the permission overwrite using Discord.js `permissionOverwrites.delete()`, handles errors with `withErrorHandling`, and returns JSON response.
    async ({ guildId, channelId, targetId, 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 guildChannel = channel as GuildChannel; await guildChannel.permissionOverwrites.delete(targetId, reason); return { channelId, channelName: channel.name, targetId, message: 'Permission overwrite 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) }] }; }
  • Input schema using Zod for validating guildId, channelId, targetId, and optional reason.
    { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), targetId: z.string().describe('The ID of the role or member'), reason: z.string().optional().describe('Reason for the deletion'), },
  • The MCP `server.tool()` registration defining name, description, schema, and handler for delete_channel_permission.
    server.tool( 'delete_channel_permission', 'Delete a permission overwrite for a role or member on a channel', { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), targetId: z.string().describe('The ID of the role or member'), reason: z.string().optional().describe('Reason for the deletion'), }, async ({ guildId, channelId, targetId, 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 guildChannel = channel as GuildChannel; await guildChannel.permissionOverwrites.delete(targetId, reason); return { channelId, channelName: channel.name, targetId, message: 'Permission overwrite 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:57-57 (registration)
    Top-level call to registerPermissionTools which registers the delete_channel_permission tool among others.
    registerPermissionTools(server);

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