Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/trustlessmatt/discord-exporter-bot/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The !export command exports all messages from your Discord server within a specified time range to a structured JSON file. This command captures complete message data including content, metadata, attachments, and reactions.

Command Syntax

!export [hours]
hours
integer
default:24
Number of hours to look back for messages
  • Minimum: 1 hour
  • Maximum: 720 hours (30 days)
  • Default: 24 hours (if not specified)

What Gets Exported

The export includes comprehensive data for each message:

Message Data

  • Message content: Original text and cleaned content (with mentions resolved)
  • Author information: Name, display name, user ID, bot status
  • Timestamps: Both Eastern Time and UTC, including edit timestamps
  • Attachments: Filename, URL, and file size for each attachment
  • Reactions: Emoji and reaction count
  • Mentions: User mentions, channel mentions, and role mentions
  • Thread information: Thread name if message is in a thread
  • Embeds: Count of embedded content

Metadata

  • Guild/server name
  • Export timestamp (ET and UTC)
  • Time range in hours
  • Channel information for each exported channel

Output Format

Exports are saved to the exports/ directory with the naming pattern:
discord_export_YYYYMMDD_HHMMSS_ET.json

JSON Structure

{
  "guild_name": "Your Server Name",
  "export_time_eastern": "2026-03-04T14:30:00-05:00",
  "export_time_utc": "2026-03-04T19:30:00+00:00",
  "timezone": "America/New_York (Eastern Time - auto DST)",
  "time_range_hours": 24,
  "channels": {
    "general": {
      "channel_id": "123456789",
      "messages": [...]
    }
  }
}

Example Usage

!export
Response:
Starting export of last 24 hours...
✅ Export complete!
• 147 messages
• 5 channels
• Saved to `exports/discord_export_20260304_143052_ET.json`

Error Handling

Invalid Hour RangeIf you specify hours outside the valid range (1-720), you’ll receive:
Hours must be between 1 and 720 (30 days)
Permission ErrorsChannels the bot cannot access are skipped with a warning in logs:
No permission to read #private-channel
The export continues for accessible channels.
Empty ExportsIf no messages are found in the time range, the export will complete successfully but with 0 messages.

Technical Details

Performance

  • Concurrent export: All channels are exported in parallel using asyncio.gather()
  • No message limit: Fetches all messages within the time range
  • Timezone handling: Automatically handles DST transitions for Eastern Time

Mention Resolution

The bot resolves Discord’s internal mention format to readable names:
  • <@123456>@Username
  • <#789012>#channel-name
  • <@&345678>@RoleName
Both original and cleaned content are included in the export.

File Location

See bot.py:204-256 for the core export implementation.

Build docs developers (and LLMs) love