Thanks to visit codestin.com
Credit goes to lib.rs

#discord-bot #importer #discord

app Dimport

Imports messages from JSON files generated by DiscordChatExporter and replaces expired links with media files downloaded by Dimage

3 stable releases

new 2025.9.21 Sep 21, 2025
2025.9.20 Sep 20, 2025

#234 in Web programming

Codestin Search App

63 downloads per month

MIT license

225KB
1.5K SLoC

Dimport

Stars Forks Watchers Repo Size Language Count Top Language Issues Last Commit Release Sponsor Build

Imports messages from JSON files generated by DiscordChatExporter and replaces expired links with media files downloaded by Dimage.

⚙️ Features

  • Imports messages from DiscordChatExporter JSON files as Discord bot messages.
  • Replaces expired attachment links with local media files downloaded by Dimage.
  • Automatically scans multiple directory structures for media files (avatars, channels, emojis).
  • Customizable Discord-like message appearance with extensive configuration options.
  • Handles multiple images per message using Discord's multi-embed system.
  • Converts reactions to interactive buttons or native Discord reactions.
  • Preserves user mentions with clickable Discord format.
  • Provides message range selection (first N, last N, or custom range).
  • Includes cancellation system for long-running imports.
  • Offers two import modes: embedded (Discord-like) and outside (raw content with attachments).
  • Supports multiple imports inside channels (multiple servers were not tested).
  • Optional embed-free import mode for minimal processing.

⚠️ Disclaimers

Discord doesn't allow sending messages and embeds from user accounts, so all imported messages are sent from the name of a Discord bot. This program tries to mimic real messages as much as possible using a variety of different options, so good luck.

🚀 Installation from crates.io

cargo install dimport

🛠️ Build from Source

git clone https://github.com/Inc44/Dimport.git
cd Dimport
cargo build --release

📦 Publish

cargo publish

🧾 Configuration

Create a .env file or set environment variables.

DISCORD_TOKEN=your_bot_token

📖 Usage Example

cargo run --release
/import "<export.json>" "<media_root>"
/cancel
/help

🎨 Command-Line Arguments

Argument Description
<json_path> Path to the DiscordChatExporter JSON file (required)
<media_path> Path to the directory containing downloaded media files (optional)
--no-guild Hide guild/server name from message footer
--no-category Hide category name from message footer
--no-channel Hide channel name from message footer
--no-timestamp Hide message timestamps
--no-mentions Skip converting @mentions to clickable Discord mentions
--no-reactions Skip importing reactions entirely
--no-embed Skip creating embeds (only works with --outside)
--button Display reactions as interactive buttons instead of native Discord reactions
--reaction-users Show detailed list of users who reacted to each message
--outside Send metadata embed separately from attachments
--disable-button Make reaction buttons unclickable (only works with --button)
--accent-color Use user accent color for embed color instead of exported role color
--current-avatar Use the user's current Discord avatar as author icon
--range <start,end> Import messages within specified range (zero-indexed)
--range-start <n> Set starting message index for import range
--range-end <n> Set ending message index for import range
--first <n> Import only the first N messages
--last <n> Import only the last N messages
--ephemeral Hide messages of /cancel and /help

🎯 Motivation

DiscordChatExporter supports only exporting. Discord-Chat-Importer has been inactive for over two years and does not support link expiration introduced in late 2023. After creating the original version of Dimage in February 2025 and updating it recently, I decided to build a new alternative from scratch in Rust. It is inspired by Discord-Chat-Importer in response style but includes new features and improved performance.

🐛 Bugs

Discord supports a maximum of 4 images per embed (PC only, 1 for other devices), not fixable yet. More details:

Discord opens the browser when clicking on a user handle instead of doing the same inside Discord, not fixable yet. More details:

set_var of dotenvy is unsafe under the Rust 2024 edition. More details:

There is an edge case that makes the original message disappear when 11 buttons are added via --button; this does not happen by default when normal reactions are used.

Cancel may not work if there are multiple imports in the same channel.

Replies are randomly marked. A possible solution is to add an option to reply as an embed to make them consistent.

⛔ Known Limitations

Discord bots can't react with the same emoji types multiple times to the message, so for mimicking multiple reactions, you can use --button. However, Discord does not support changing button text on click natively, so the button's reaction count doesn't change. Also, to avoid getting "Button interaction failed," you can freeze/disable buttons to make them unclickable using --disable-button, which unfortunately makes them grayed out. If you do not want to import reactions, you can use --no-reactions. So, good luck choosing your poison.

/import can't be registered as a slash command because it has too many flags or options, and it makes the bot send separate messages instead of one stream. Therefore, its output cannot be ephemeral. Embeds are not suppressed for /help when ephemeral is used, probably because they disappear anyway.

<json_path> can be a link, either Google Drive download type https://drive.usercontent.google.com/download?id=... or GitHub raw type https://raw.githubusercontent.com/user/repo/refs/heads/master/.... However, other websites may not work for unknown reasons, like some temporary clipboards https://nopaste.net/....

Emojis that do not belong to the server are not visible.

Content like embeds or polls is not imported.

🚧 TODO

  • Import from current channel to another channel
  • /delete (last import, last n imports, all imports)
  • Tests (json, media)

🙏 Thanks

Creators of:

People:

🤝 Contribution

Contributions, suggestions, and new ideas are heartily welcomed. If you're considering significant modifications, please initiate an issue for discussion before submitting a pull request.

📜 License

MIT

This project is licensed under the MIT License. See the LICENSE file for details.

💖 Support

BuyMeACoffee Ko-Fi Patreon

Dependencies

~23–41MB
~642K SLoC