# Dimport






[](https://github.com/Inc44/Dimport/issues?q=is%3Aopen+is%3Aissue)

[](https://github.com/Inc44/Dimport/releases)
[](https://github.com/sponsors/Inc44)
[](https://github.com/Inc44/Dimage/actions/workflows/build.yml)
Imports messages from JSON files generated by [DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter) and replaces expired links with media files downloaded by [Dimage](https://github.com/Inc44/Dimage).
## โ๏ธ Features
- Imports messages from [DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter) JSON files as Discord bot messages.
- Replaces expired attachment links with local media files downloaded by [Dimage](https://github.com/Inc44/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
```bash
cargo install dimport
```
## ๐ ๏ธ Build from Source
```bash
git clone https://github.com/Inc44/Dimport.git
cd Dimport
cargo build --release
```
## ๐ฆ Publish
```bash
cargo publish
```
## ๐งพ Configuration
Create a `.env` file or set environment variables.
```
DISCORD_TOKEN=your_bot_token
```
## ๐ Usage Example
```bash
cargo run --release
```
```
/import "<export.json>" "<media_root>"
```
```
/cancel
```
```
/help
```
## ๐จ Command-Line Arguments
| Argument | Description |
|-----------------------|-------------------------------------------------------------------------------------------------------|
| `<json_path>` | Path to the [DiscordChatExporter](https://github.com/Tyrrrz/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](https://github.com/Tyrrrz/DiscordChatExporter) supports only exporting. [Discord-Chat-Importer](https://github.com/Ethorbit/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](https://github.com/Inc44/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](https://github.com/Ethorbit/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:
- [Is it possible to attach multiple images in an embed?](https://stackoverflow.com/questions/57182398/is-it-possible-to-attach-multiple-images-in-a-embed)
- [Finally a way to display multiple images in an Embed!](https://www.reddit.com/r/discordapp/comments/raz4kl/finally_a_way_to_display_multiple_images_in_an)
Discord opens the browser when clicking on a user handle instead of doing the same inside Discord, not fixable yet. More details:
- [Open a user's profile when sending a link like https://discord.com/users/USER_ID](https://github.com/discord/discord-api-docs/discussions/5183)
`set_var` of [dotenvy](https://github.com/allan2/dotenvy) is unsafe under the Rust 2024 edition. More details:
- [Functions that modify the environment have undocumented safety requirements](https://github.com/allan2/dotenvy/issues/112)
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:
- [Rust](https://www.rust-lang.org)
- [Serenity and Poise](https://serenity-rs.github.io)
- [Serde](https://serde.rs)
- [Tokio](https://tokio.rs)
- [walkdir](https://github.com/BurntSushi/walkdir)
- [dotenvy](https://github.com/allan2/dotenvy)
- [reqwest](https://github.com/seanmonstar/reqwest)
- [zip](https://github.com/zip-rs/zip2)
- [tempfile](https://github.com/Stebalien/tempfile)
People:
- Sharing how to send multiple images inside one embed
- [Is it possible to attach multiple images in an embed?](https://stackoverflow.com/questions/57182398/is-it-possible-to-attach-multiple-images-in-a-embed)
- [Finally a way to display multiple images in an Embed!](https://www.reddit.com/r/discordapp/comments/raz4kl/finally_a_way_to_display_multiple_images_in_an)
## ๐ค 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
[](https://opensource.org/licenses/MIT)
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## ๐ Support
[](https://buymeacoffee.com/xamituchido)
[](https://ko-fi.com/inc44)
[](https://www.patreon.com/Inc44)