discord_read_messages
Retrieve recent messages from a Discord text channel to monitor conversations or extract information.
Instructions
Read the last N messages from a text channel.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | Yes | ||
| limit | No | 1–100, default 20. |
Implementation Reference
- src/tools/messages.ts:297-308 (handler)The handler logic for 'discord_read_messages' which fetches the last N messages from a discord channel.
case "discord_read_messages": { const channel = await getTextChannel(args.channel_id as string); const limit = Math.min(Number(args.limit ?? 20), 100); const messages = await channel.messages.fetch({ limit }); const result = [...messages.values()] .sort((a, b) => a.createdTimestamp - b.createdTimestamp) .map((m) => ({ id: m.id, author: m.author.tag, content: m.content, timestamp: m.createdAt.toISOString(), attachments: m.attachments.size, pinned: m.pinned, })); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/tools/messages.ts:7-18 (schema)The schema registration for 'discord_read_messages' defining input parameters.
{ name: "discord_read_messages", description: "Read the last N messages from a text channel.", inputSchema: { type: "object", properties: { channel_id: { type: "string" }, limit: { type: "number", description: "1–100, default 20." }, }, required: ["channel_id"], }, },