Skip to main content
Glama

get_channel_info

Retrieve detailed information about a specific Discord channel by providing server and channel IDs to access channel data.

Instructions

Get detailed information about a specific channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel

Implementation Reference

  • Registration of the 'get_channel_info' tool, including schema, description, and handler function.
    server.tool( 'get_channel_info', 'Get detailed information about a specific channel', { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), }, async ({ guildId, channelId }) => { 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'); // Cast to GuildChannel for common properties const guildChannel = channel as GuildChannel; const baseInfo: Record<string, unknown> = { id: channel.id, name: channel.name, type: channel.type, typeName: ChannelType[channel.type], parentId: guildChannel.parentId, createdAt: channel.createdAt?.toISOString(), }; // Add position and permission overwrites for non-thread channels if ('position' in guildChannel) { baseInfo.position = guildChannel.position; } if ('permissionOverwrites' in guildChannel && guildChannel.permissionOverwrites) { baseInfo.permissionOverwrites = guildChannel.permissionOverwrites.cache.map((po) => ({ id: po.id, type: po.type, allow: po.allow.toArray(), deny: po.deny.toArray(), })); } // Add text channel specific info if (channel.type === ChannelType.GuildText || channel.type === ChannelType.GuildAnnouncement) { const textChannel = channel as TextChannel; return { ...baseInfo, topic: textChannel.topic, nsfw: textChannel.nsfw, rateLimitPerUser: textChannel.rateLimitPerUser, }; } // Add voice channel specific info if (channel.type === ChannelType.GuildVoice || channel.type === ChannelType.GuildStageVoice) { const voiceChannel = channel as VoiceChannel; return { ...baseInfo, bitrate: voiceChannel.bitrate, userLimit: voiceChannel.userLimit, rtcRegion: voiceChannel.rtcRegion, }; } return baseInfo; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
  • The handler function that implements the core logic of fetching channel details from Discord, handling different channel types, and returning formatted JSON.
    async ({ guildId, channelId }) => { 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'); // Cast to GuildChannel for common properties const guildChannel = channel as GuildChannel; const baseInfo: Record<string, unknown> = { id: channel.id, name: channel.name, type: channel.type, typeName: ChannelType[channel.type], parentId: guildChannel.parentId, createdAt: channel.createdAt?.toISOString(), }; // Add position and permission overwrites for non-thread channels if ('position' in guildChannel) { baseInfo.position = guildChannel.position; } if ('permissionOverwrites' in guildChannel && guildChannel.permissionOverwrites) { baseInfo.permissionOverwrites = guildChannel.permissionOverwrites.cache.map((po) => ({ id: po.id, type: po.type, allow: po.allow.toArray(), deny: po.deny.toArray(), })); } // Add text channel specific info if (channel.type === ChannelType.GuildText || channel.type === ChannelType.GuildAnnouncement) { const textChannel = channel as TextChannel; return { ...baseInfo, topic: textChannel.topic, nsfw: textChannel.nsfw, rateLimitPerUser: textChannel.rateLimitPerUser, }; } // Add voice channel specific info if (channel.type === ChannelType.GuildVoice || channel.type === ChannelType.GuildStageVoice) { const voiceChannel = channel as VoiceChannel; return { ...baseInfo, bitrate: voiceChannel.bitrate, userLimit: voiceChannel.userLimit, rtcRegion: voiceChannel.rtcRegion, }; } return baseInfo; }); 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 the input parameters: guildId and channelId.
    { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the channel'), },
  • src/index.ts:54-54 (registration)
    High-level registration call that invokes registerChannelTools, which includes the get_channel_info tool.
    registerChannelTools(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