Command-line Discord archival tool, with static HTML exports
discord archive cli
1

Configure Feed

Select the types of activity you want to include in your feed.

Rust 91.9%
HTML 4.7%
CSS 3.3%
Just 0.2%
17 1 2

Clone this repository

https://tangled.org/kokirigla.de/darkive https://tangled.org/did:plc:n3kxpdtviturpu7imurulsfe
git@tangled.org:kokirigla.de/darkive git@tangled.org:did:plc:n3kxpdtviturpu7imurulsfe

For self-hosted knots, clone URLs may differ based on your setup.



README.md

darkive#

CAUTION

Do NOT use this program with your main Discord account, or an account you care about.

Using this program with a user account token violates the Discord Terms of Service and WILL MOST LIKELY result in your account being suspended or banned permanently. When possible, USE A BOT TOKEN.

If using a bot token is not practical for your use-case (e.g you want to archive a public server you aren't an administrator of), you should ALWAYS use an alternate account, NOT your main Discord account.

HTML export limitations#

The export is currently plain text only. The following are not yet rendered:

  • Attachments and uploaded files
  • Embeds (link previews, rich embeds)
  • Components (buttons, select menus, etc.)
  • Custom emoji (only the name is shown, e.g. :wave:)
  • Markdown formatting (bold, italic, code blocks, etc.)
  • Reactions
  • Replies and threads

As these features are added, they will be compatible with existing archives. A re-export should be all that is needed.

Installation#

Windows#

  1. Download darkive_cli.exe from the current release.
  2. Create a folder for darkive somewhere convenient, e.g. C:\Users\YourName\Documents\darkive.
  3. Move darkive_cli.exe into that folder.

Linux, macOS#

  1. Install Rust via rustup.
  2. Clone the repository:
    git clone git@tangled.org:did:plc:n3kxpdtviturpu7imurulsfe darkive
    cd darkive
    
  3. Build the release binary:
    cargo build --release
    
    The binary will be at target/release/darkive_cli.

When following the rest of this guide, substitute ./target/release/darkive_cli wherever you see .\darkive_cli.exe. For the .env file, create it with any text editor in the cloned repository folder.

Setup#

Providing your Discord token#

darkive reads your token from a .env file in the same folder as the exe. This keeps it out of your command history.

  1. Open Notepad.
  2. Type exactly (replacing the placeholder with your real token):
    DISCORD_TOKEN=paste_your_token_here
    
  3. Save the file into your darkive folder as .env with no .txt extension. In the Save dialog, set Save as type to All Files and type .env as the filename.

Getting a bot token#

  1. Go to the Discord Developer Portal and create a new application.
  2. Open the Bot tab and click Reset Token to reveal your token. Copy it into the .env file.
  3. On the same page, scroll down and enable Server Members Intent and Message Content Intent.
  4. Invite the bot to your server: go to OAuth2 -> URL Generator, select the bot scope, and tick at minimum Read Messages/View Channels and Read Message History. Open the generated URL in your browser to invite it.

Getting a user token#

CAUTION

Using a user token violates Discord's Terms of Service. Only do this on an account you are willing to lose.

Open Discord in a browser, press F12, go to the Network tab, send any message, click on a request to discord.com, and look for the Authorization header in the request headers. That value is your user token.

Finding server and channel IDs#

  1. In Discord, open Settings -> Advanced and enable Developer Mode.
  2. Right-click any server icon in the sidebar and choose Copy Server ID.
  3. Right-click any channel name and choose Copy Channel ID.

Opening a terminal in your darkive folder#

Hold Shift and right-click your darkive folder in File Explorer, then choose Open PowerShell window here. All commands below should be run in this window.

Archiving#

Basic usage - bot token#

.\darkive_cli.exe archive --token-type bot --server-ids 123456789012345678

Replace 123456789012345678 with your server's ID.

Basic usage - user token#

.\darkive_cli.exe archive --token-type user --server-ids 123456789012345678

Archiving multiple servers at once#

Separate server IDs with commas and no spaces:

.\darkive_cli.exe archive --token-type bot --server-ids 111111111111111111,222222222222222222

Skipping channels#

.\darkive_cli.exe archive --token-type bot --server-ids 123456789012345678 --ignored-channel-ids 987654321098765432,876543210987654321

Skipping large files#

To skip attachments over a certain size, pass the limit in bytes. For example, to skip anything over 10 MB:

.\darkive_cli.exe archive --token-type bot --server-ids 123456789012345678 --max-file-size 10485760

Skipping specific file types#

See here for a list of example types.

.\darkive_cli.exe archive --token-type bot --server-ids 123456789012345678 --blacklist-content-types video/mp4,video/webm

Archiving messages only (no file downloads)#

.\darkive_cli.exe archive --token-type bot --server-ids 123456789012345678 --no-download

Smart resume#

Smart resume is optional. If an archive run stops halfway through, rerun with --smart-resume and it will:

  • skip channels that already finished successfully
  • resume message backfill from the oldest message already stored for a channel
  • discover newly archived threads without paging through the full archived-thread history again
.\darkive_cli.exe archive --token-type bot --server-ids 123456789012345678 --smart-resume

Custom output folder#

By default the archive is saved to an archive subfolder next to the exe. To change it:

.\darkive_cli.exe archive --token-type bot --server-ids 123456789012345678 --output-dir C:\Users\YourName\Documents\my-archive

The archive folder contains:

  • archive.db - SQLite database with all messages, members, and metadata
  • files\ - downloaded attachments, avatars, emojis, and other media

Exporting to HTML#

Once you have an archive, export it to a static website you can browse locally:

.\darkive_cli.exe export

This reads from the archive folder and writes HTML files to an export folder. Open export\index.html in your browser to browse the archive. By default, export\files\ is linked back to the archive's existing files\ directory instead of copying every asset into export\.

Custom folders#

.\darkive_cli.exe export --archive-dir C:\Users\YourName\Documents\my-archive --output C:\Users\YourName\Documents\my-export

Copying files into the export#

If you want a self-contained export directory, add --copy-files:

.\darkive_cli.exe export --copy-files

Changing messages per page#

.\darkive_cli.exe export --page-size 500

All options at a glance#

archive#

Option Required Default Description
--token-type Yes - bot or user
--server-ids Yes - Comma-separated server IDs to archive
--ignored-channel-ids No - Comma-separated channel IDs to skip
--output-dir No archive Where to save the database and files
--blacklist-content-types No - MIME types to skip downloading (e.g. video/mp4)
--max-file-size No - Skip files larger than this many bytes
--no-download No - Archive messages only, skip all file downloads
--skip-intent-wait No - Skip the 30-second startup delay for bot tokens
--smart-resume No false Resume interrupted history backfill and only scan newer archived-thread pages

export#

Option Required Default Description
--archive-dir No archive Path to the archive directory
--output / -o No export Output directory for the static site
--page-size No 250 Number of messages per HTML page
--copy-files No false Copy archive files into the export directory instead of linking export/files back to the archive's existing files directory