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
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| channelId | Yes | The ID of the channel |
Implementation Reference
- src/tools/channel-tools.ts:49-119 (registration)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) }] }; } );
- src/tools/channel-tools.ts:56-118 (handler)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) }] }; }
- src/tools/channel-tools.ts:52-55 (schema)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);