Discord get messages

From evolution-foundation/evo-nexus · View interactive version

Discord get messages is an AI agent skill from the GitHub repository evolution-foundation/evo-nexus. Retrieve messages from Discord channels via the Discord API. Use this skill when the user wants to read, search, or analyze messages from a Discord channel.

How to use this skill

Skill file

Discord Get Messages

Retrieve messages from Discord channels using the Discord API v10. This skill supports pagination, filtering by message count, and retrieving message history.

When to Use This Skill

Use this skill when the user wants to:

Prerequisites

Instructions

When the user requests to retrieve Discord messages:

  1. Validate Requirements
  1. Prepare Query Parameters
  1. Make the API Request

Use the following curl command structure:

```bash

curl -X GET "https://discord.com/api/v10/channels/{CHANNEL_ID}/messages?limit=50" \

-H "Authorization: Bot ${DISCORD_BOT_TOKEN}"

```

Replace:

  1. Process Response
  1. Handle Response Codes
  1. Present Results

Query Parameters

Limit

?limit=10  # Get 10 most recent messages (default: 50, max: 100)

Before (Pagination)

?before=1234567890123456789&limit=50  # Get 50 messages before this message ID

After

?after=1234567890123456789&limit=50  # Get 50 messages after this message ID

Around

?around=1234567890123456789&limit=50  # Get 50 messages around this message ID

Message Object Structure

Each message returned contains:

{
  "id": "1234567890123456789",
  "channel_id": "123456789012345678",
  "author": {
    "id": "987654321098765432",
    "username": "Username",
    "discriminator": "0000",
    "avatar": "avatar_hash"
  },
  "content": "Message text content",
  "timestamp": "2025-10-20T12:00:00.000000+00:00",
  "edited_timestamp": null,
  "tts": false,
  "mention_everyone": false,
  "mentions": [],
  "mention_roles": [],
  "attachments": [],
  "embeds": [],
  "reactions": [],
  "pinned": false,
  "type": 0
}

Formatting Output

Simple Format

[2025-10-20 12:00] Username: Message content here
[2025-10-20 11:55] OtherUser: Another message

Detailed Format

Message ID: 1234567890123456789
Author: Username#0000 (987654321098765432)
Timestamp: 2025-10-20T12:00:00.000000+00:00
Content: Message text content here
Attachments: image.png (https://cdn.discordapp.com/...)

Filtering and Processing

Filter by Author

After retrieving messages, filter by author ID or username:

# Get messages then filter in output
curl ... | jq '.[] | select(.author.username == "TargetUser")'

Filter by Content

Search for specific keywords in message content:

# Get messages then search content
curl ... | jq '.[] | select(.content | contains("keyword"))'

Get Only Text Messages

Exclude system messages and embeds:

# Filter message type 0 (default text messages)
curl ... | jq '.[] | select(.type == 0)'

Pagination Strategy

To retrieve more than 100 messages:

  1. Get first batch: ?limit=100
  2. Get oldest message ID from response
  3. Get next batch: ?before={oldest_id}&limit=100
  4. Repeat until all messages retrieved or desired count reached

Example:

# First batch
curl "https://discord.com/api/v10/channels/{CHANNEL_ID}/messages?limit=100" \
  -H "Authorization: Bot ${DISCORD_BOT_TOKEN}"

# Get oldest message ID from response (e.g., 1234567890123456789)

# Next batch
curl "https://discord.com/api/v10/channels/{CHANNEL_ID}/messages?before=1234567890123456789&limit=100" \
  -H "Authorization: Bot ${DISCORD_BOT_TOKEN}"

Error Handling

Common Errors

401 Unauthorized

403 Forbidden

404 Not Found

400 Bad Request

Rate Limiting

Security Notes

Performance Tips

Examples

See examples.md for detailed usage scenarios.

API Reference

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.