get_pinned_messages
Retrieve all pinned messages from a specific Discord channel to access important announcements and key information.
Instructions
Get all pinned messages in a 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/message-tools.ts:285-317 (registration)Registration of the 'get_pinned_messages' tool. Includes input schema (guildId and channelId) and the handler function that fetches and returns pinned messages from the specified Discord channel using channel.messages.fetchPinned().'get_pinned_messages', 'Get all pinned messages in a 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 (!isMessageableChannel(channel)) { throw new Error('Channel does not support messages'); } const pinned = await channel.messages.fetchPinned(); return pinned.map((msg) => ({ id: msg.id, content: msg.content, authorId: msg.author.id, authorUsername: msg.author.username, createdAt: msg.createdAt.toISOString(), })); }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );