DiscordChatExporter

repository·prime·Indexed 10 days ago

https://github.com/tyrrrz/discordchatexporter

A tool for exporting Discord message history from direct messages, group chats, and server channels into HTML, JSON, CSV, and TXT formats. Available as both a GUI desktop application and a CLI for automation. Supports user and bot tokens, rich media preservation, and advanced filtering for offline viewing.

Tokens
3.1K
Snippets
16
Records
20
Agent score
95%

What's inside DiscordChatExporter

  1. Overview of DiscordChatExporter features

    prime

    DiscordChatExporter is used to export message history from Discord channels (Direct Messages, Group Messages, and Server Channels) to local files.

    Key Capabilities

    • Authentication: Supports both user tokens and bot tokens.
    • Output Formats: Export to HTML (with dark/light themes), TXT, CSV, or JSON.
    • Rich Media Support: Preserves Discord's markdown dialect, attachments, embeds, and emojis.
    • Advanced Filtering: Supports file partitioning, specific date ranges, and message filtering.
    • Offline Viewing: Produces self-contained exports that can be viewed without an internet connection.
    WARNING

    Automating user accounts is against Discord's Terms of Service and may result in account bans. It is recommended to use a bot for exporting logs from accessible channels whenever possible.

  2. Install the DiscordChatExporter GUI

    prime

    The Graphical User Interface (GUI) version is a desktop application for users who prefer a visual interface. You can install it via several package managers or download the stable release directly.

    Package Managers

    • Scoop: scoop install extras/discordchatexporter
    • WinGet: winget install Tyrrrz.DiscordChatExporter.GUI
    • AUR (Arch Linux): yay -S discord-chat-exporter-gui
    • Nix: nix-shell -p discordchatexporter-desktop

    Manual Download

    Download the DiscordChatExporter.*.zip file from the latest stable releases.

    MacOS Setup

    If you are on MacOS, you may need to remove the downloaded file from quarantine to launch the app. Run the following command in your terminal: xattr -rd com.apple.quarantine DiscordChatExporter.app

    # Example: Installing via WinGet
    winget install Tyrrrz.DiscordChatExporter.GUI
    
    # Example: Removing MacOS quarantine
    xattr -rd com.apple.quarantine DiscordChatExporter.app
  3. Install the DiscordChatExporter CLI

    prime

    The Command-Line Interface (CLI) version is a terminal application suitable for automation and scripting.

    Package Managers

    • Docker: docker pull tyrrrz/discordchatexporter
    • WinGet: winget install Tyrrrz.DiscordChatExporter.CLI
    • AUR (Arch Linux): yay -S discord-chat-exporter-cli
    • Nix: nix-shell -p discordchatexporter-cli

    Manual Download

    Download the DiscordChatExporter.Cli.*.zip file from the latest stable releases.

    # Example: Pulling the Docker image
    docker pull tyrrrz/discordchatexporter
    
    # Example: Installing via WinGet
    winget install Tyrrrz.DiscordChatExporter.CLI
  4. Run DiscordChatExporter CLI tests locally

    prime

    To run the test suite locally, you must join the dedicated test Discord server and provide a valid Discord authentication token via user secrets. This allows the tests to interact with a real Discord environment designed to exercise specific behaviors.

    1. Join the test server: https://discord.gg/eRV8Vap5bm
    2. Obtain your Discord authentication token.
    3. Store your token in your local user secrets using the DISCORD_TOKEN key.
    4. Execute the tests using the dotnet CLI.
    # Set your authentication token
    dotnet user-secrets set DISCORD_TOKEN <token>
    
    # Run the tests
    dotnet test
  5. How to obtain a Bot Token

    prime

    If you are using a bot, you need the token generated during the bot's creation. If you have lost it, you can reset it via the Discord Developer Portal:

    1. Go to the Discord developer portal.
    2. Open your application's settings.
    3. Navigate to the Bot section on the left.
    4. Under Token, click Reset Token.
    5. Click Yes, do it! and authenticate to confirm.

    Note:

    • Integrations using the previous token will stop working until updated.
    • Your bot must have the Message Content Intent enabled in the developer portal to read messages.
  6. How to obtain a User Token

    prime

    To use DiscordChatExporter with a personal account, you need your authorization token.

    Warning: Automating user accounts is technically against Discord's Terms of Service. Use at your own risk.

    1. Open Discord in your web browser and login.
    2. Open any server or direct message channel.
    3. Press Ctrl+Shift+I to show developer tools.
    4. Navigate to the Network tab.
    5. Press Ctrl+R to reload.
    6. Switch between random channels to trigger network requests.
    7. Search for a request that starts with "messages".
    8. Select the Headers tab on the right.
    9. Scroll down to the Request Headers section.
    10. Copy the value of the "authorization" header.
  7. Reference: `exportall` command options

    prime

    The following options are available for the exportall command to filter content or specify the data source.

    --include-dm             Include direct message channels. (Default: true)
    --include-guilds         Include server channels. (Default: true)
    --include-vc             Include voice channels. (Default: true)
    --data-package <path>    Path to the personal data package (ZIP file) requested from Discord. If provided, only channels referenced in the dump will be exported.
  8. Configure thread inclusion mode

    prime

    When exporting chats, you can specify how threads (such as forum posts or specific thread types) are included in the export using the ThreadInclusionMode option. This determines whether the exporter ignores threads, only includes active ones, or includes all available threads.

    ThreadInclusionMode:
    - None: No threads are included in the export.
    - Active: Only active threads are included.
    - All: All threads are included in the export.
  9. Reference: `channels` command options

    prime

    The following options are available for the channels command:

    OptionShortDescription
    --guild-gThe ID of the server (guild) to fetch channels from. (Required)
    --include-vcWhether to include voice channels in the list. Defaults to true.
    --include-threadsSpecifies which types of threads should be included. Uses ThreadInclusionMode values. Defaults to None.
    --guild <GUILD_ID>
    --include-vc
    --include-threads <MODE>