Skip to main content
The Discord resource exposes guild, channel, and member data as a virtual filesystem mounted at some prefix such as /discord/. For token setup, see Discord Setup.

Config

Filesystem Layout

Example:
Display names keep their original spelling from Discord (spaces, apostrophes, emoji are all preserved). Only / is replaced with (U+2215) so it cannot collide with a directory boundary. The Discord snowflake ID is appended after __ (double underscore) on guild, channel, member, and attachment names so resource specific commands can extract it without an extra lookup, and so two same named entities never collide. Quote names containing spaces in shell commands. stat also exposes the ID in the extra dict (see Finding IDs).

Guilds

The root lists one directory per guild the bot has access to.

Channels

/discord/<guild>/channels/ lists text channels (types 0, 5, 15). Each channel directory contains day-partitioned directories for the 30 days leading up to the channel’s last message. Each day directory holds:
  • chat.jsonl, the day’s messages (one JSON object per line).
  • files/, attachments posted on that day. Each blob is named <stem>__<attachment-id>.<ext>, where the stem keeps the original filename’s spelling (only / is replaced). The ID suffix keeps the filename collision-free. cat’ing a blob downloads it from the Discord CDN.
The date range is derived from last_message_id on the channel object, so inactive channels show dates around their last activity, not today. Soft errors (403 missing permissions, 404 unknown channel, 429 rate limit) on a single day are swallowed so listings, find, and grep keep working across the rest of the tree.

Members

/discord/<guild>/members/ lists one .json file per member. Reading a member file returns the full member payload from the Discord API.

Smart Commands

grep / rg at different scopes

When grep or rg target a channel or guild directory (not a specific file), they use the Discord search API instead of downloading every .jsonl file:
Scope detection is handled by mirage/core/discord/scope.py.

head / tail

head and tail on file-level paths use the Discord messages API directly (GET /channels/{id}/messages) instead of downloading the full day’s history.

Cache

The Discord resource uses IndexCacheStore (same as RAM/S3/disk/GitHub). Index entries store guild IDs, channel IDs, and last_message_id for date range computation. There is no separate content cache - file content caching is handled by the workspace IOResult mechanism.

Example

See examples/python/discord/discord.py for the full working example.

Finding IDs

Resource-specific commands require Discord snowflake IDs (channel_id, guild_id, message_id). These can be extracted from the filesystem:

Working with Large Channels

Tips for efficient access on busy channels:
Note: grep/rg at channel or guild level uses the Discord search API instead of downloading every .jsonl file, making it efficient even for large channels.

Shell Commands

Standard commands available on the mounted Discord tree: Acting on Discord (sending, editing, reactions, threads, polls, member and guild info, search) goes through the discord CLI when installed; the mounted tree stays read-oriented. The <name>__<id> path segments supply the snowflake IDs the CLI flags take.