mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-07-07 22:54:38 +02:00
Compare commits
290 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5623c2ca34 | |||
| 8525917a4c | |||
| b9c1c47474 | |||
| 74f99b4e59 | |||
| 12b590d9f9 | |||
| 6d1e8c2e02 | |||
| 72f02cd9a0 | |||
| 47d560229d | |||
| 0e87098889 | |||
| 0139eeaeed | |||
| c0ea57e9b1 | |||
| 7c04db40f8 | |||
| 4588bd0496 | |||
| 3a22db14a7 | |||
| ba72927c37 | |||
| 822bab2365 | |||
| 211db11041 | |||
| 9b8985a920 | |||
| 014712b747 | |||
| d8e43d89be | |||
| 4e69ff317b | |||
| 057beaacd6 | |||
| 982ba6a76c | |||
| dccd9a2f08 | |||
| 182f24846b | |||
| 777f92a3f1 | |||
| d4be307fb1 | |||
| 2bbb585931 | |||
| 73080ecfa6 | |||
| 0745d49f44 | |||
| c16e14e9b6 | |||
| 8e36002ae7 | |||
| a2c5d2e2dd | |||
| 4e3deb409c | |||
| 512f181be2 | |||
| e04eb890e6 | |||
| 1ad42ee48b | |||
| b8a67617bc | |||
| 062427d143 | |||
| 5f343a46d1 | |||
| b3a1cbf635 | |||
| 619fe9ccf7 | |||
| 174b92cbb0 | |||
| d0873ecfa7 | |||
| cfbbc4b8e2 | |||
| ee436f8e68 | |||
| cf77cb4688 | |||
| 309e58116a | |||
| 116cdc0746 | |||
| d481f73020 | |||
| daa6f1e696 | |||
| e6f9a364e1 | |||
| 0f6841593f | |||
| 2262d0abfb | |||
| ab535233dc | |||
| dcaceaddaf | |||
| 2a787d2749 | |||
| 481ddc4cd5 | |||
| c493518eaf | |||
| 450866d1f5 | |||
| 60c8703e78 | |||
| 1c343b75f8 | |||
| b2a22ab2a9 | |||
| b2ac5d8b45 | |||
| 008c2e64aa | |||
| 576ee73bfc | |||
| db1da5545a | |||
| 5397b0db7d | |||
| e89701e3f9 | |||
| a46bf9bf11 | |||
| 8dc024d244 | |||
| 9a125db0ea | |||
| d9c35f4405 | |||
| 5846129cc6 | |||
| 6f5f747632 | |||
| 6a71c59b6d | |||
| 73574ade48 | |||
| 743db67f91 | |||
| 5d7a74eece | |||
| 129df42de4 | |||
| 6508455f3a | |||
| 50b26c557f | |||
| b709fc0f15 | |||
| c118a0bb94 | |||
| 1418bec0c7 | |||
| 750fd69a50 | |||
| b1297bb7df | |||
| 3189111a0e | |||
| 6ec2c04aa3 | |||
| 7c014bf64d | |||
| c875f8f4f0 | |||
| 69e2c337d8 | |||
| 77c770acdd | |||
| 6f8749a105 | |||
| 4896d748aa | |||
| 4876ed192a | |||
| 4f6e6f4f0b | |||
| 8c75f04115 | |||
| df04b123cd | |||
| 578ed9be17 | |||
| ebceacc707 | |||
| eaab5786f2 | |||
| ebf7d65334 | |||
| 52a23828ce | |||
| 2edd781e32 | |||
| 19cdf47c6e | |||
| 65e0a63bda | |||
| 692438d10c | |||
| c607c6f307 | |||
| aae43821e7 | |||
| 7b9a4e1aff | |||
| d8e57f94a8 | |||
| 7b7df564ed | |||
| 80b59d1254 | |||
| 6579563816 | |||
| e2971ed3a6 | |||
| a0a263f074 | |||
| 1438fd9f77 | |||
| b298b45cf7 | |||
| 8d01c6be35 | |||
| ce4dbb2616 | |||
| 033d83bc4f | |||
| fb6cde38b6 | |||
| 46ede471a9 | |||
| 09f8937d99 | |||
| ad2dab2157 | |||
| c5e426289f | |||
| b8e5034aea | |||
| 5fc40fe7d5 | |||
| f7d94975b2 | |||
| 3eb0421ec6 | |||
| 57ed5578c9 | |||
| a8895663fe | |||
| 89f2084759 | |||
| 9180d51e5e | |||
| a58509fda8 | |||
| fbfff4e51f | |||
| c466c17793 | |||
| 1b2bcf771d | |||
| 99b49f0b8f | |||
| 850414b017 | |||
| 92bf6eab2d | |||
| 16d44ce654 | |||
| 5abe74894c | |||
| 59344cedbe | |||
| 53b11d6c49 | |||
| ccdf082689 | |||
| 9601e0acea | |||
| 9583e2684d | |||
| d24550f521 | |||
| c422ac2351 | |||
| 3740d64601 | |||
| d430f77ae1 | |||
| 5f6e51f6fb | |||
| f1c094ac14 | |||
| 6fb6108610 | |||
| e75a1933f8 | |||
| 20f58963a6 | |||
| c410e745b1 | |||
| c29de2c77c | |||
| 67d41fbdc4 | |||
| 041086267c | |||
| 47588296a9 | |||
| d1a8f466f6 | |||
| 758fb26dad | |||
| 8236ba7c4d | |||
| eac974cfb1 | |||
| d1d560fb55 | |||
| 6fba60e570 | |||
| ac1bd16439 | |||
| 60389ab002 | |||
| 817d54039b | |||
| 0ca42f5a14 | |||
| 193cfd7b1e | |||
| 21293dc7af | |||
| 88dee76690 | |||
| cd5afd07ac | |||
| 55270ad6d3 | |||
| e82ad2b9c6 | |||
| dd0a35838d | |||
| c9b68427f3 | |||
| 1ba0057174 | |||
| d00ecf0c37 | |||
| b224fca6c0 | |||
| c9447c5c8f | |||
| de67cfae1c | |||
| 4efa6094dc | |||
| 088612a78f | |||
| de531d4a97 | |||
| 5fc2fae28a | |||
| ddfbe51cfa | |||
| bcf652edbe | |||
| 1f5407f032 | |||
| 83a63c2ed7 | |||
| f33a0ac0a7 | |||
| 779b8984d7 | |||
| 3e44a2e88d | |||
| b44e6087be | |||
| 49b96087d3 | |||
| e175c93038 | |||
| 0ee1107638 | |||
| 81a6d363d1 | |||
| 90d71c5b9e | |||
| 5e9c7392db | |||
| c4137cf77e | |||
| 51192425b7 | |||
| 8776a6955b | |||
| c69211797f | |||
| 768fb88c8c | |||
| d4f62387a5 | |||
| bd4cfcdaf6 | |||
| c3abeadf01 | |||
| 86ee9c8d5f | |||
| c99355dec3 | |||
| 11d34109a7 | |||
| 609ca0fc0d | |||
| 6cadb19cc8 | |||
| d02649773e | |||
| 18d9c189b7 | |||
| 3d2d197904 | |||
| bf0d8ab31e | |||
| 30b447d2ae | |||
| 3d047321cf | |||
| 6d787c4071 | |||
| d779ed9bc8 | |||
| 3319b4734d | |||
| e052241713 | |||
| 2b7f1ed4ed | |||
| 03784f0d7c | |||
| e7310274ba | |||
| 4eab781450 | |||
| 6582e26cd3 | |||
| c48899e0b1 | |||
| 41b4e47d0e | |||
| 6bbde4ccdc | |||
| 469a731892 | |||
| d8315c7827 | |||
| a4111c184e | |||
| c945c98f75 | |||
| 31c7ae9312 | |||
| 03c5c1bc5e | |||
| 0ae9062a30 | |||
| 25caf04445 | |||
| 9048557b17 | |||
| faad994332 | |||
| d7537425f8 | |||
| e261edde8b | |||
| 72bb886a5e | |||
| 9428d5ed56 | |||
| b8b1fdb1d1 | |||
| 168b3c2f31 | |||
| 9575fd11b5 | |||
| a332bda07d | |||
| c3f181c9e0 | |||
| b9cd40f211 | |||
| ab933a7240 | |||
| a9fc439cc5 | |||
| d4f5fc5efc | |||
| 505330e117 | |||
| 36db99b5cf | |||
| a4110a362f | |||
| 0ab8bd67c4 | |||
| 31952a109e | |||
| 2e1636e6c9 | |||
| 20e782e6ed | |||
| ebb838bb81 | |||
| 966627f289 | |||
| 4ec00d0ec8 | |||
| 8bc1bcaf16 | |||
| 8f40acdda7 | |||
| bbe18368fa | |||
| 48eece554c | |||
| 7d7f1cc1e5 | |||
| 2a1998b81c | |||
| ac7f08ff3e | |||
| 95c5a43f6e | |||
| 91afded824 | |||
| 0981c51fb9 | |||
| 55209a0517 | |||
| c2c35cf3a3 | |||
| 404542d973 | |||
| f36852a1a2 | |||
| 0e1c3e4c76 | |||
| 83e3289ead | |||
| b51900ec6a | |||
| d1647e8286 | |||
| 95115f3e99 | |||
| 53ff8ba430 | |||
| cbab5fb71c | |||
| 9512729ec2 |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 19 KiB |
+40
-70
@@ -2,108 +2,78 @@
|
|||||||
|
|
||||||
Docker distribution of DiscordChatExporter provides a way to run the app in a virtualized and isolated environment. Due to the nature of Docker, you also don't need to install any prerequisites otherwise required by DCE.
|
Docker distribution of DiscordChatExporter provides a way to run the app in a virtualized and isolated environment. Due to the nature of Docker, you also don't need to install any prerequisites otherwise required by DCE.
|
||||||
|
|
||||||
Note that only the CLI flavor of DiscordChatExporter is available for use with Docker.
|
> **Note**:
|
||||||
|
> Only the CLI flavor of DiscordChatExporter is available for use with Docker.
|
||||||
|
|
||||||
## Pulling
|
## Pulling
|
||||||
|
|
||||||
This will download the [Docker image from the registry](https://hub.docker.com/r/tyrrrz/discordchatexporter) to your computer. You can run this command again to update when a new version is released.
|
This will download the [Docker image from the registry](https://hub.docker.com/r/tyrrrz/discordchatexporter) to your computer. You can run this command again to update when a new version is released.
|
||||||
|
|
||||||
```
|
```console
|
||||||
docker pull tyrrrz/discordchatexporter:stable
|
$ docker pull tyrrrz/discordchatexporter:stable
|
||||||
```
|
```
|
||||||
|
|
||||||
Note the `:stable` tag. DiscordChatExporter images are tagged according to the following patterns:
|
Note the `:stable` tag. DiscordChatExporter images are tagged according to the following patterns:
|
||||||
|
|
||||||
- `stable`: Latest stable version release and maps to the latest GitHub release. This tag is updated with release of each new version. Recommended for personal use.
|
- `stable` — latest stable version release. This tag is updated with each release of a new project version. Recommended for personal use.
|
||||||
- `latest`: Built from the latest commit and maps to the latest CI build on GitHub. This tag is updated with each new commit to `master` branch. Not recommended for everyday use, but you can use it if you want to try out some features that haven't been officially released yet.
|
- `x.y.z` (e.g. `2.30.1`) — specific stable version release. This tag is pushed when the corresponding version is released and never updated thereafter. Recommended for use in automation scenarios.
|
||||||
- `x.y.z` (e.g. `2.30.1`): Fixed version release and maps to the corresponding tag on GitHub. This tag is never updated once that version has been released. Recommended for use in various automation scenarios.
|
- `latest` — latest (potentially unstable) build. This tag is updated with each new commit to the `master` branch. Not recommended, unless you want to test a new feature that has not been released in a stable version yet.
|
||||||
|
|
||||||
You can see all available tags [here](https://hub.docker.com/r/tyrrrz/discordchatexporter/tags?page=1&ordering=name).
|
You can see all available tags [here](https://hub.docker.com/r/tyrrrz/discordchatexporter/tags?ordering=name).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To run the CLI in Docker and render help text:
|
To run the CLI in Docker and render help text:
|
||||||
|
|
||||||
```
|
```console
|
||||||
docker run --rm tyrrrz/discordchatexporter:stable
|
$ docker run --rm tyrrrz/discordchatexporter:stable
|
||||||
```
|
```
|
||||||
|
|
||||||
To export a channel:
|
To export a channel:
|
||||||
|
|
||||||
```
|
```console
|
||||||
docker run --rm -v /path/on/machine:/out tyrrrz/discordchatexporter:stable export -t TOKEN -c CHANNELID
|
$ docker run --rm -v /path/on/machine:/out tyrrrz/discordchatexporter:stable export -t TOKEN -c CHANNELID
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want colored output, real-time progress reporting, and some other stuff, pass `-it` (interactive) option:
|
If you want colored output and real-time progress reporting, pass the `-it` (interactive + pseudo-terminal) option:
|
||||||
|
|
||||||
```
|
```console
|
||||||
docker run --rm -it -v /path/on/machine:/out tyrrrz/discordchatexporter:stable export -t TOKEN -c CHANNELID
|
$ docker run --rm -it -v /path/on/machine:/out tyrrrz/discordchatexporter:stable export -t TOKEN -c CHANNELID
|
||||||
```
|
```
|
||||||
|
|
||||||
Note the `-v /path/on/machine:/out` option, which instructs Docker to bind the `/out` directory inside the container to a path on your host machine. Replace `/path/on/machine` with the directory you want the files to be saved at.
|
The `-v /path/on/machine:/out` option instructs Docker to bind the `/out` directory inside the container to a path on your host machine. Replace `/path/on/machine` with the directory you want the files to be saved at.
|
||||||
|
|
||||||
**If you are running SELinux, you will need to add the `:z` option after `/out`, e.g.:**
|
> **Note**:
|
||||||
|
> If you are running SELinux, you will need to add the `:z` option after `/out`, e.g.:
|
||||||
```
|
>
|
||||||
docker run --rm -v /path/on/machine:/out:z tyrrrz/discordchatexporter:stable export -t TOKEN -c CHANNELID
|
> ```console
|
||||||
```
|
> $ docker run --rm -v /path/on/machine:/out:z tyrrrz/discordchatexporter:stable export -t TOKEN -c CHANNELID
|
||||||
|
> ```
|
||||||
For more information, refer to the [Docker docs SELinux labels for bind mounts page](https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label).
|
>
|
||||||
|
> For more information, refer to the [Docker docs SELinux labels for bind mounts page](https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label).
|
||||||
|
|
||||||
You can also use the current working directory as the output directory by specifying:
|
You can also use the current working directory as the output directory by specifying:
|
||||||
|
|
||||||
- `-v $PWD:/out` in Mac/Linux
|
- `-v $PWD:/out` in Bash
|
||||||
- `-v $pwd.Path:/out` in PowerShell
|
- `-v $pwd.Path:/out` in PowerShell
|
||||||
|
|
||||||
For more information, please refer to the [Dockerfile](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/Dockerfile) and [Docker documentation](https://docs.docker.com/engine/reference/run/).
|
For more information, please refer to the [Dockerfile](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/DiscordChatExporter.Cli.dockerfile) and [Docker documentation](https://docs.docker.com/engine/reference/run).
|
||||||
|
|
||||||
To get your Token and Channel IDs, please refer to [this page](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
To get your Token and Channel IDs, please refer to [this page](Token-and-IDs.md).
|
||||||
|
|
||||||
|
## Unix permissions issues
|
||||||
|
|
||||||
|
This image was designed with a user running as uid:gid of 1000:1000.
|
||||||
|
|
||||||
|
If your current user has different IDs, and you want to generate files directly editable for your user, you might want to run the container like this:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ mkdir data # or chown -R $(id -u):$(id -g) data
|
||||||
|
$ docker run -it --rm -v $PWD/data:/out --user $(id -u):$(id -g) tyrrrz/discordchatexporter:stable export -t TOKEN -g CHANNELID
|
||||||
|
```
|
||||||
|
|
||||||
## Environment variables
|
## Environment variables
|
||||||
|
|
||||||
DiscordChatExpoter CLI accepts environment variables as fallbacks for the `--token` and `--bot` options.
|
DiscordChatExpoter CLI accepts the `DISCORD_TOKEN` environment variable as a fallback for the `--token` option. You can set this variable either with the `--env` Docker option or with a combination of the `--env-file` Docker option and a `.env` file.
|
||||||
|
|
||||||
- `DISCORD_TOKEN` to set the token
|
Please refer to the [Docker documentation](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file) for more information.
|
||||||
- `DISCORD_TOKEN_BOT` to set whether it's a bot token (`true` or `false`)
|
|
||||||
|
|
||||||
You can use these variables either with the `--env` Docker option or with a combination of the `--env-file` Docker option and a `.env` file.
|
|
||||||
Please refer to the Docker documentation for more information:
|
|
||||||
|
|
||||||
- [Docker run - Set environment variables](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)
|
|
||||||
|
|
||||||
## Permission issues with Linux hosts
|
|
||||||
|
|
||||||
When bounding volumes between the container and the host, files mirrored from the Docker container will be owned by the Docker user (in most setups this is `root`). Please refer to this [issue comment](https://github.com/Tyrrrz/DiscordChatExporter/issues/800#issuecomment-1030471970) for instructions on how to override this behavior.
|
|
||||||
|
|
||||||
## Build Docker images for arm on Raspberry Pi
|
|
||||||
|
|
||||||
If you use the Docker image on arm (for example Raspberry Pi), you'd build the image as below.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ git clone https://github.com/Tyrrrz/DiscordChatExporter.git
|
|
||||||
$ cd DiscordChatExporter
|
|
||||||
$ docker build -f DiscordChatExporter.Cli.dockerfile -t tyrrrz/discordchatexporter:latest .
|
|
||||||
```
|
|
||||||
|
|
||||||
After a while, some images are built like below.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ docker image ls
|
|
||||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
|
||||||
tyrrrz/discordchatexporter latest 7c9ead725177 49 seconds ago 199MB
|
|
||||||
<none> <none> 57f9f49d05af About a minute ago 678MB
|
|
||||||
mcr.microsoft.com/dotnet/sdk 5.0 72af6071941e 4 days ago 641MB
|
|
||||||
mcr.microsoft.com/dotnet/runtime 3.1 6229bebd5a11 4 days ago 197MB
|
|
||||||
```
|
|
||||||
|
|
||||||
Among these, two images (`tyrrrz/discordchatexporter:latest` and `mcr.microsoft.com/dotnet/runtime:3.1`) are required, so you may delete the other two images.
|
|
||||||
|
|
||||||
Now you can execute DiscordChatExporter:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ docker run --rm tyrrrz/discordchatexporter:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Special thanks to [@simnalamburt](https://github.com/simnalamburt) (dockerize) and [@Nimja](https://github.com/nimja) (better instructions)
|
|
||||||
|
|||||||
+24
-43
@@ -1,68 +1,49 @@
|
|||||||
# Install .NET runtime
|
# Install .NET runtime
|
||||||
|
|
||||||
**.NET v7.0 Runtime** is required by **DiscordChatExporter v2.37 and newer**.
|
**.NET 8.0 Runtime** is required by **DiscordChatExporter**.
|
||||||
|
|
||||||
If you are using GUI flavor of DiscordChatExporter, the runtime will be installed automatically (since v2.27.1).
|
> **Note**:
|
||||||
If you are using the CLI from Docker, installing the runtime on the host machine is not needed.
|
> Installing the **.NET Runtime** is not required if you running **DiscordChatExporter** using [Docker](Docker.md).
|
||||||
|
|
||||||
- Install
|
## Windows
|
||||||
- [Windows and macOS](#windows-and-macos)
|
|
||||||
- [Linux](#linux)
|
|
||||||
- [Docker](#docker)
|
|
||||||
- [Verify installation](#Verify-installation-optional)
|
|
||||||
|
|
||||||
## Windows and macOS
|
Both the GUI and the CLI flavors of **DiscordChatExporter** for Windows come with a bootstrapper that should automatically install all the required prerequisites. Simply run the application and follow the presented instructions.
|
||||||
|
|
||||||
**Download from the direct links:**
|
If, for some reason, you need to install the runtime manually, use one of the download links below:
|
||||||
|
|
||||||
- [.NET v7.0 Runtime for **Windows x64**](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-7.0.1-windows-x64-installer)
|
- [.NET 8.0 Runtime for **Windows x64**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-windows-x86-installer)
|
||||||
- [.NET v7.0 Runtime for **Windows x86**](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-7.0.1-windows-x86-installer)
|
- [.NET 8.0 Runtime for **Windows x86**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-windows-x64-installer)
|
||||||
- [.NET v7.0 Runtime for **Macs with Apple silicon**](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-7.0.1-macos-arm64-installer)
|
- [.NET 8.0 Runtime for **Windows arm64**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-windows-arm64-installer)
|
||||||
- [.NET v7.0 Runtime for **Macs with an Intel processor**](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-7.0.1-macos-x64-installer)
|
|
||||||
|
|
||||||
> **Note**:
|
> **Note**:
|
||||||
> [How can I tell if my computer is running a 32-bit (x86) or a 64-bit (x64) version of Windows?](https://support.microsoft.com/help/15056/windows-32-64-bit-faq)
|
> [How can I tell if my computer is running a 32-bit (x86) or a 64-bit (x64) version of Windows?](https://support.microsoft.com/help/15056/windows-32-64-bit-faq)
|
||||||
|
|
||||||
|
## macOS
|
||||||
|
|
||||||
|
Use one of the download links below:
|
||||||
|
|
||||||
|
- [.NET 8.0 Runtime for **macOS x64**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-macos-x64-installer)
|
||||||
|
- [.NET 8.0 Runtime for **macOS arm64**](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.0-macos-arm64-installer)
|
||||||
|
|
||||||
> **Note**:
|
> **Note**:
|
||||||
> [Is my Mac using an Intel processor or Apple silicon?](https://support.apple.com/HT211814)
|
> [Is my Mac using an Intel processor (x64) or Apple Silicon (arm64)?](https://support.apple.com/HT211814)
|
||||||
|
|
||||||
**Otherwise:**
|
|
||||||
[Check out the latest version in this page](https://dotnet.microsoft.com/download/dotnet/7.0).
|
|
||||||
Look for the download link in the '**.NET Runtime**' section, under **Installers**:
|
|
||||||
|
|
||||||
[](https://dotnet.microsoft.com/download/dotnet/7.0)
|
|
||||||
|
|
||||||
## Linux
|
## Linux
|
||||||
|
|
||||||
**You only need to install .NET Runtime v7.0**
|
Installing the .NET Runtime works differently depending on which Linux distribution you use. Check out the instructions for your distro:
|
||||||
|
|
||||||
Check out the instructions for your distro:
|
- [Ubuntu](https://docs.microsoft.com/dotnet/core/install/linux-ubuntu)
|
||||||
|
- [Debian](https://docs.microsoft.com/dotnet/core/install/linux-debian)
|
||||||
- [Ubuntu](https://docs.microsoft.com/dotnet/core/install/linux-ubuntu#supported-distributions)
|
- [Fedora](https://docs.microsoft.com/dotnet/core/install/linux-fedora)
|
||||||
- [Debian](https://docs.microsoft.com/dotnet/core/install/linux-debian#supported-distributions)
|
|
||||||
- [Fedora](https://docs.microsoft.com/dotnet/core/install/linux-fedora#supported-distributions)
|
|
||||||
|
|
||||||
For other distros, please check the _'Install on Linux'_ menu on the left of [this page](https://docs.microsoft.com/dotnet/core/install/linux).
|
For other distros, please check the _'Install on Linux'_ menu on the left of [this page](https://docs.microsoft.com/dotnet/core/install/linux).
|
||||||
|
|
||||||
## Docker
|
|
||||||
|
|
||||||
Installing .NET Runtime is not needed. Please refer to the [Docker usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md) page for more information.
|
|
||||||
|
|
||||||
## Verify installation (optional)
|
## Verify installation (optional)
|
||||||
|
|
||||||
You can check which version of **.NET Runtime** is installed by following these instructions:
|
You can check which version of **.NET Runtime** is installed by running the following command in a terminal:
|
||||||
|
|
||||||
### Step 1
|
```console
|
||||||
|
$ dotnet --info
|
||||||
**Windows:** Open Command Prompt (aka `cmd`)
|
|
||||||
**macOS and Linux:** Open `Terminal`
|
|
||||||
|
|
||||||
### Step 2
|
|
||||||
|
|
||||||
Run: `dotnet --info`
|
|
||||||
If **.NET Runtime** is correctly installed, the command will output the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
.NET runtimes installed:
|
.NET runtimes installed:
|
||||||
Microsoft.NETCore.App 7.0.x [C:\path\to\dotnet\shared\Microsoft.NETCore.App]
|
Microsoft.NETCore.App 7.0.x [C:\path\to\dotnet\shared\Microsoft.NETCore.App]
|
||||||
|
|||||||
+9
-455
@@ -2,466 +2,27 @@
|
|||||||
|
|
||||||
Welcome to the getting started page!
|
Welcome to the getting started page!
|
||||||
Here you'll learn how to use every **DiscordChatExporter** (DCE for short) feature.
|
Here you'll learn how to use every **DiscordChatExporter** (DCE for short) feature.
|
||||||
For other things you can do with DCE, check out the [Guides](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Readme.md#Guides) section.
|
For other things you can do with DCE, check out the [Guides](Readme.md#guides) section.
|
||||||
|
|
||||||
If you still have unanswered questions after reading this page or if you have encountered a problem, please visit our [FAQ & Troubleshooting](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md) section.
|
If you still have unanswered questions after reading this page or if you have encountered a problem, please visit our [FAQ & Troubleshooting](Troubleshooting.md) section.
|
||||||
|
|
||||||
The information presented on this page is valid for **all** platforms.
|
The information presented on this page is valid for **all** platforms.
|
||||||
|
|
||||||
## GUI or CLI?
|
## GUI or CLI?
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
**DCE** has two different versions:
|
**DCE** has two different versions:
|
||||||
|
|
||||||
- **Graphical User Interface** (**GUI**) - it's the preferred version for newcomers as it is easy to use.
|
- **Graphical User Interface** (**GUI**) - it's the preferred version for newcomers as it is easy to use.
|
||||||
You can get it by [downloading](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest) the `DiscordChatExporter.zip` file.
|
You can get it by [downloading](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest) the `DiscordChatExporter.*.zip` file.
|
||||||
- **Command-line Interface** (**CLI**) - offers greater flexibility and more features for advanced users, such as export scheduling, ID lists, and more specific date ranges.
|
- **Command-line Interface** (**CLI**) - offers greater flexibility and more features for advanced users, such as export scheduling, ID lists, and more specific date ranges.
|
||||||
You can get it by [downloading](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest) the `DiscordChatExporter.CLI.zip` file.
|
You can get it by [downloading](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest) the `DiscordChatExporter.Cli.*.zip` file.
|
||||||
|
|
||||||
If you're not comfortable with **Windows'** Command-line (cmd), please choose the GUI.
|
There are dedicated guides for each version:
|
||||||
[**macOS**](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/MacOS.md), [**Linux**](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Linux.md) and [**Docker**](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md) users can only use the CLI version.
|
|
||||||
|
|
||||||
**(Skip to [Using the CLI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#using-the-cli) or [File Formats](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats))**
|
- [Using the GUI](Using-the-GUI.md)
|
||||||
|
- [Using the CLI](Using-the-CLI.md)
|
||||||
## Using the GUI
|
|
||||||
|
|
||||||
### Video tutorial
|
|
||||||
|
|
||||||
[](https://youtube.com/watch?v=jjtu0VQXV7I)
|
|
||||||
|
|
||||||
> Video by [NoIntro Tutorials](https://youtube.com/channel/UCFezKSxdNKJe77-hYiuXu3Q).
|
|
||||||
|
|
||||||
### Guide
|
|
||||||
|
|
||||||
1. After extracting the `.zip`, open `DiscordChatExporter.exe`
|
|
||||||
2. Please refer to the on-screen instructions to get your token, then paste your token in the upper text box and hit ENTER or click the arrow (→).
|
|
||||||
|
|
||||||
> **Warning**:
|
|
||||||
> **Never share your token!**
|
|
||||||
> A token gives full access to an account, treat it like a password.
|
|
||||||
|
|
||||||
<img src="https://i.imgur.com/SuLQ5tZ.png" height="400"/>
|
|
||||||
|
|
||||||
3. DCE will display your Direct Messages and a sidebar with your server list. Select the channel you would like to export, then click the  button to continue.
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> You can export multiple channels at once by holding `CTRL` or `SHIFT` while selecting.
|
|
||||||
> You can also double-click a channel to export it without clicking the  button.
|
|
||||||
|
|
||||||
<img src="https://i.imgur.com/JHMFRh2.png" height="400"/>
|
|
||||||
|
|
||||||
4. In this screen you can customize the following:
|
|
||||||
|
|
||||||
- **Export format** - HTML (Dark), HTML (Light), TXT, CSV and JSON
|
|
||||||
|
|
||||||
Click the menu button (☰) to see more options:
|
|
||||||
|
|
||||||
- **Date range (after/before)** (Optional) - If set, only messages sent in the provided date range will be exported. Only one value (either after or before) is required if you want to use this option.
|
|
||||||
> **Note**:
|
|
||||||
> Please note that the time defaults to **12:00 AM** (midnight/00:00). This means that if you choose to export between Sep 17th and Sep 18th, messages from Sep 18th won't be exported.
|
|
||||||
- **Filter** (Optional) - Special notation for filtering the messages that get included in the export. See [Message filters](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) for more info.
|
|
||||||
- **Messages per partition** (Optional) - Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb). For example, a channel with 36 messages set to be partitioned every 10 messages will output 4 files.
|
|
||||||
- **Download assets** (Optional) - If this option is set, the export will include additional files such as user avatars, attached files, images, etc.
|
|
||||||
Only files that are referenced by the export are downloaded, which means that, for example, user avatars will not be downloaded when using the plain text (TXT) export format.
|
|
||||||
A folder containing the assets will be created along with the exported chat. They must be kept together.
|
|
||||||
|
|
||||||
5. Click `EXPORT` to export.
|
|
||||||
|
|
||||||
<img src="https://i.imgur.com/KPgMH2D.png" height="400"/><img src="https://i.imgur.com/mtUFojS.png" height="400"/>
|
|
||||||
|
|
||||||
### Settings
|
|
||||||
|
|
||||||
**Auto-updates**
|
|
||||||
Perform automatic updates on every launch.
|
|
||||||
Default: Enabled
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Keep this option enabled to receive the latest features and bug fixes!
|
|
||||||
|
|
||||||
**Dark mode**
|
|
||||||
Use darker colors in the UI (User Interface).
|
|
||||||
Default: Disabled
|
|
||||||
|
|
||||||
**Save token**
|
|
||||||
Persist last used token between sessions.
|
|
||||||
Default: Enabled
|
|
||||||
|
|
||||||
**Reuse downloaded assets**
|
|
||||||
Reuse already downloaded assets to skip redundant requests.
|
|
||||||
Default: Disabled
|
|
||||||
|
|
||||||
**Date format**
|
|
||||||
You can customize how dates are formatted in the exported files in the settings menu ().
|
|
||||||
|
|
||||||
- The default one is `17-Sep-19 11:34 PM` - `dd-MMM-yy hh:mm tt`
|
|
||||||
- To change it to `09-17-19 11:34 PM` use `MM-dd-yy hh:mm tt`
|
|
||||||
- To change it to `17/09/2019 23:34` use `dd/MM/yyyy HH:mm`
|
|
||||||
- To change it to `2019-09-17 23:34:05.6534` use `yyyy-MM-dd HH:mm:ss.ffff`
|
|
||||||
- To change it to UTC `2019-09-18 04:34:05Z` use `u`
|
|
||||||
- To display the time zone, add `K`. E.g. to change it to `17-Sep-19 11:34 PM (UTC-05:00)` use `dd-MMM-yy hh:mm tt (UTCK)`
|
|
||||||
- To change it to Unix time `1568694845` use `unix`
|
|
||||||
- To change it to Unix time in milliseconds `1568694845653` use `unixms`
|
|
||||||
|
|
||||||
More info about .NET date formats [here](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings).
|
|
||||||
|
|
||||||
**Parallel limit**
|
|
||||||
The number of channels can be exported at the same time.
|
|
||||||
Default: 1
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Try to keep this number low so that your account doesn't get flagged.
|
|
||||||
|
|
||||||
**(Skip to [File Formats](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats))**
|
|
||||||
|
|
||||||
## Using the CLI
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Make sure you have [.NET Core installed](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md) before attempting to run the commands below.
|
|
||||||
> **Docker** users, please refer to the [Docker usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md).
|
|
||||||
|
|
||||||
1. After extracting the `.zip`, open Command Prompt, aka `cmd` (`Terminal` on **macOS** and **Linux**).
|
|
||||||
|
|
||||||
2. Change the current directory to DCE's folder with `cd C:\path\to\directory`, then press ENTER to run the command.
|
|
||||||
|
|
||||||
**Windows** users can quickly get the directory's path by clicking the address bar while inside the folder.
|
|
||||||

|
|
||||||
**macOS** users can select the `.exe`, hit Command+I (⌘I), and copy what's after `Where:` to get the directory
|
|
||||||

|
|
||||||
You can also drag and drop the folder on **every platform**.
|
|
||||||

|
|
||||||
|
|
||||||
3. Now we're ready to run the commands. The examples on this page follow the Windows file path format, change the file paths according to your system.
|
|
||||||
|
|
||||||
Let's do the following to list DCE's options:
|
|
||||||
|
|
||||||
Type the following in Command Prompt (Terminal), then press ENTER to run it:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll
|
|
||||||
```
|
|
||||||
|
|
||||||
> **Docker** users, please refer to the [Docker usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md).
|
|
||||||
|
|
||||||
### DCE.CLI commands
|
|
||||||
|
|
||||||
| Command | Description |
|
|
||||||
| ------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
|
|
||||||
| [export](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#export) | Exports a channel |
|
|
||||||
| [exportdm](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#exportdm) | Exports all direct message channels |
|
|
||||||
| [exportguild](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#exportguild) | Exports all channels within the specified server |
|
|
||||||
| [exportall](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#exportall) | Exports all accessible channels |
|
|
||||||
| [channels](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#channels) | Outputs the list of channels in the given server |
|
|
||||||
| [dm](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#dm) | Outputs the list of direct message channels |
|
|
||||||
| [guilds](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#guilds) | Outputs the list of accessible servers |
|
|
||||||
| [guide](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#guide) | Explains how to obtain token, guild, and channel ID |
|
|
||||||
|
|
||||||
To use the commands, you'll need a token. For the instructions on how to get a token, please refer to [this page](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md), or run `dotnet DiscordChatExporter.Cli.dll guide`.
|
|
||||||
To get help with a specific command, please run:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll command -h
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `export`
|
|
||||||
|
|
||||||
| | Option | Description |
|
|
||||||
| ------ | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\*** | [-c](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Channel ID(s)](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-guild-id-or-guild-channel-id) |
|
|
||||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
|
||||||
| | [-o](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-output-filename) | Output file or directory path |
|
|
||||||
| | [-f](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-format) | [Output file format](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats). Default: HtmlDark |
|
|
||||||
| | [--after](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-ranges) | Only include messages sent after this date |
|
|
||||||
| | [--before](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-ranges) | Only include messages sent before this date |
|
|
||||||
| | [-p](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#partitioning) | Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb) |
|
|
||||||
| | [--filter](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) | Special notation for filtering the messages that get included in the export |
|
|
||||||
| | [--media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#Downloading-assets) | Download assets referenced by the export (user avatars, attached files, embedded images, etc.). Default: false |
|
|
||||||
| | [--reuse-media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#Reuse-assets) | Reuse previously downloaded assets to avoid redundant requests. Default: false. |
|
|
||||||
| | [--dateformat](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-formats) | Format used when writing dates. |
|
|
||||||
| | -h | Shows help text |
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
|
||||||
|
|
||||||
With this command you can export Server Channels and Direct Messages.
|
|
||||||
|
|
||||||
##### Basic usage
|
|
||||||
|
|
||||||
You can quickly export with DCE's default settings by using just `-t token` and `-c channelid`.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Changing the format
|
|
||||||
|
|
||||||
You can change the export format to `HtmlDark`, `HtmlLight`, `PlainText` `Json` or `Csv` with `-f format`. The default format is `HtmlDark`.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -f Json
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Changing the output filename
|
|
||||||
|
|
||||||
You can change the filename by using `-o name.ext`. e.g. for the `HTML` format:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -o myserver.html
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Changing the output directory
|
|
||||||
|
|
||||||
You can change the export directory by using `-o` and providing a path that ends with a slash or does not have a file extension.
|
|
||||||
If any of the folders in the path have a space in its name, escape them with quotes (").
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -o "C:\Discord Exports"
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Changing the filename and output directory
|
|
||||||
|
|
||||||
You can change both the filename and export directory by using `-o directory\name.ext`.
|
|
||||||
Note that the filename must have an extension, otherwise it will be considered a directory name.
|
|
||||||
If any of the folders in the path have a space in its name, escape them with quotes (").
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -o "C:\Discord Exports\myserver.html"
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Generating the filename and output directory dynamically
|
|
||||||
|
|
||||||
You can use template tokens to generate the output file path based on the guild and channel metadata.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -o "C:\Discord Exports\%G\%T\%C.html"
|
|
||||||
```
|
|
||||||
|
|
||||||
Assuming you are exporting a channel named `"my-channel"` in the `"Text channels"` category from a server called `"My server"`, you will get the following output file path: `C:\Discord Exports\My server\Text channels\my-channel.html`
|
|
||||||
|
|
||||||
Here is the full list of supported template tokens:
|
|
||||||
|
|
||||||
- `%g` - guild ID
|
|
||||||
- `%G` - guild name
|
|
||||||
- `%t` - category ID
|
|
||||||
- `%T` - category name
|
|
||||||
- `%c` - channel ID
|
|
||||||
- `%C` - channel name
|
|
||||||
- `%p` - channel position
|
|
||||||
- `%P` - category position
|
|
||||||
- `%a` - the "after" date
|
|
||||||
- `%b` - the "before" date
|
|
||||||
- `%%` - escapes `%`
|
|
||||||
|
|
||||||
##### Partitioning
|
|
||||||
|
|
||||||
You can use partitioning to split files after a given number of messages or file size.
|
|
||||||
For example, a channel with 36 messages set to be partitioned every 10 messages will output 4 files.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -p 10
|
|
||||||
```
|
|
||||||
|
|
||||||
A 45mb channel set to be partitioned every 20mb will output 3 files.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 -p 20mb
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Downloading assets
|
|
||||||
|
|
||||||
If this option is set, the export will include additional files such as user avatars, attached files, images, etc.
|
|
||||||
Only files that are referenced by the export are downloaded, which means that, for example, user avatars will not be downloaded when using the plain text (TXT) export format.
|
|
||||||
A folder containing the assets will be created along with the exported chat. They must be kept together.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --media
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Reuse assets
|
|
||||||
|
|
||||||
Previously downloaded assets can be reused to skip redundant downloads as long as the chat is always exported to the same folder. Using this option can speed up future exports. This option requires the `--media` option.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --media --reuse-media
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Date formats
|
|
||||||
|
|
||||||
This setting changes how dates are formatted in the exported files.
|
|
||||||
|
|
||||||
- The default one is `17-Sep-19 11:34 PM` - `dd-MMM-yy hh:mm tt`
|
|
||||||
- To change it to `09-17-19 11:34 PM` use `MM-dd-yy hh:mm tt`
|
|
||||||
- To change it to `17/09/2019 23:34` use `dd/MM/yyyy HH:mm`
|
|
||||||
- To change it to `2019-09-17 23:34:05.6534` use `yyyy-MM-dd HH:mm:ss.ffff`
|
|
||||||
- To change it to UTC `2019-09-18 04:34:05Z` use `u`
|
|
||||||
- To display the time zone, add `K`. E.g. to change it to `17-Sep-19 11:34 PM (UTC-05:00)` use `dd-MMM-yy hh:mm tt (UTCK)`
|
|
||||||
- To change it to Unix time `1568694845` use `unix`
|
|
||||||
- To change it to Unix time in milliseconds `1568694845653` use `unixms`
|
|
||||||
|
|
||||||
More info about .NET date formats [here](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings).
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --dateformat "yyyy-MM-dd HH:mm"
|
|
||||||
```
|
|
||||||
|
|
||||||
> Special thanks to [@andrewkolos](https://github.com/andrewkolos) for adding the Unix options
|
|
||||||
|
|
||||||
##### Date ranges
|
|
||||||
|
|
||||||
**Messages sent before a date**
|
|
||||||
Use `--before` to export messages sent before the provided date. E.g. messages sent before September 18th, 2019:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --before 2019-09-18
|
|
||||||
```
|
|
||||||
|
|
||||||
**Messages sent after a date**
|
|
||||||
Use `--after` to export messages sent after the provided date. E.g. messages sent after September 17th, 2019 11:34 PM:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --after "2019-09-17 23:34"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Messages sent in a date range**
|
|
||||||
Use `--before` and `--after` to export messages sent during the provided date range. E.g. messages sent between September 17th, 2019 11:34 PM and September 18th:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t "mfa.Ifrn" -c 53555 --after "2019-09-17 23:34" --before "2019-09-18"
|
|
||||||
```
|
|
||||||
|
|
||||||
You can try different formats like `17-SEP-2019 11:34 PM` or even refine your ranges down to milliseconds `17-SEP-2019 23:45:30.6170`!
|
|
||||||
Don't forget to quote (") the date if it has spaces!
|
|
||||||
More info about .NET date formats [here](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings).
|
|
||||||
|
|
||||||
#### `exportdm`
|
|
||||||
|
|
||||||
| | Option | Description |
|
|
||||||
| ------ | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
|
||||||
| | --parallel | Limits how many channels can be exported in parallel. Try to keep this number low so that your account doesn't get flagged. Default: 1 |
|
|
||||||
| | [-o](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-output-filename) | Output file or directory path |
|
|
||||||
| | [-f](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-format) | [Output file format](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats). Default: HtmlDark |
|
|
||||||
| | [--after](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-ranges) | Only include messages sent after this date |
|
|
||||||
| | [--before](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-ranges) | Only include messages sent before this date |
|
|
||||||
| | [-p](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#partitioning) | Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb) |
|
|
||||||
| | [--filter](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) | Special notation for filtering the messages that get included in the export |
|
|
||||||
| | [--media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#Downloading-assets) | Download assets referenced by the export (user avatars, attached files, embedded images, etc.). Default: false |
|
|
||||||
| | [--reuse-media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#Reuse-assets) | Reuse previously downloaded assets to avoid redundant requests. Default: false. |
|
|
||||||
| | [--dateformat](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-formats) | Date format used in output |
|
|
||||||
| | -h | Shows help text |
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
|
||||||
|
|
||||||
This command exports all your Direct Messages.
|
|
||||||
|
|
||||||
#### `exportguild`
|
|
||||||
|
|
||||||
| | Option | Description |
|
|
||||||
| ------ | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\*** | -g | [Server ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-guild-id-or-guild-channel-id) |
|
|
||||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
|
||||||
| | --parallel | Limits how many channels can be exported in parallel. Try to keep this number low so that your account doesn't get flagged. Default: 1 |
|
|
||||||
| | [-o](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-output-filename) | Output file or directory path |
|
|
||||||
| | [-f](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-format) | [Output file format](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats). Default: HtmlDark |
|
|
||||||
| | [--after](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-ranges) | Only include messages sent after this date |
|
|
||||||
| | [--before](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-ranges) | Only include messages sent before this date |
|
|
||||||
| | [-p](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#partitioning) | Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb) |
|
|
||||||
| | [--filter](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) | Special notation for filtering the messages that get included in the export |
|
|
||||||
| | [--media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#Downloading-assets) | Download assets referenced by the export (user avatars, attached files, embedded images, etc.). Default: false |
|
|
||||||
| | [--reuse-media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#Reuse-assets) | Reuse previously downloaded assets to avoid redundant requests. Default: false. |
|
|
||||||
| | [--dateformat](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-formats) | Date format used in output |
|
|
||||||
| | -h | Shows help text |
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
|
||||||
|
|
||||||
This command exports all channels of a Server.
|
|
||||||
|
|
||||||
#### `exportall`
|
|
||||||
|
|
||||||
| | Option | Description |
|
|
||||||
| ------ | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
|
||||||
| | --include-dm | Include direct message channels. Default: true |
|
|
||||||
| | --parallel | Limits how many channels can be exported in parallel. Try to keep this number low so that your account doesn't get flagged. Default: 1 |
|
|
||||||
| | [-o](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-output-filename) | Output file or directory path |
|
|
||||||
| | [-f](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#changing-the-format) | [Output file format](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats). Default: HtmlDark |
|
|
||||||
| | [--after](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-ranges) | Only include messages sent after this date |
|
|
||||||
| | [--before](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-ranges) | Only include messages sent before this date |
|
|
||||||
| | [-p](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#partitioning) | Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb) |
|
|
||||||
| | [--filter](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md) | Special notation for filtering the messages that get included in the export |
|
|
||||||
| | [--media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#Downloading-assets) | Download assets referenced by the export (user avatars, attached files, embedded images, etc.). Default: false |
|
|
||||||
| | [--reuse-media](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#Reuse-assets) | Reuse previously downloaded assets to avoid redundant requests. Default: false. |
|
|
||||||
| | [--dateformat](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#date-formats) | Date format used in output |
|
|
||||||
| | -h | Shows help text |
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
|
||||||
|
|
||||||
This command exports all accessible channels, including server channels and DMs.
|
|
||||||
|
|
||||||
To exclude DMs, add the `--include-dm false` option:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll exportall -t "mfa.Ifrn" --include-dm false
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `channels`
|
|
||||||
|
|
||||||
| | Option | Description |
|
|
||||||
| ------ | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\*** | -g | [Server ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-guild-id-or-guild-channel-id) |
|
|
||||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
|
||||||
| | -h | Shows help text |
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
|
||||||
|
|
||||||
This command outputs the server channels in the following format:
|
|
||||||
`Channel ID | Channel Name`
|
|
||||||
To save the output to a file, run the command below. If the file already exists, it will be overwritten.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll channels -t "mfa.Ifrn" -g 21814 > C:\path\to\output.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `dm`
|
|
||||||
|
|
||||||
| | Option | Description |
|
|
||||||
| ------ | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
|
||||||
| | -h | Shows help text |
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
|
||||||
|
|
||||||
This command outputs the list of Direct Messages.
|
|
||||||
To save the output to a file, run the command with `> C:\path\…` like the example below. If the file already exists, it will be overwritten.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll dm -t "mfa.Ifrn" > C:\path\to\output.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `guilds`
|
|
||||||
|
|
||||||
| | Option | Description |
|
|
||||||
| ------ | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\*** | [-t](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#basic-usage) | [Authorization token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-user-token). Environment variable: `DISCORD_TOKEN` |
|
|
||||||
| | -h | Shows help text |
|
|
||||||
|
|
||||||
> **Note**:
|
|
||||||
> Options with an asterisk (**\***) are required. The order of the options doesn't matter.
|
|
||||||
|
|
||||||
This command outputs a list of your Server List.
|
|
||||||
To save the output to a file, run the command with `> C:\path\…` like the example below. If the file already exists, it will be overwritten.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet DiscordChatExporter.Cli.dll guilds -t "mfa.Ifrn" > C:\path\to\output.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `guide`
|
|
||||||
|
|
||||||
This command explains [how to get your token, guild, and channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
|
||||||
|
|
||||||
## File formats
|
## File formats
|
||||||
|
|
||||||
@@ -497,10 +58,3 @@ You can open `.json` files with a text editor, such as Notepad.
|
|||||||
|
|
||||||
The CSV format allows for easy parsing of the chat log. Depending on your needs, the JSON format might be better.
|
The CSV format allows for easy parsing of the chat log. Depending on your needs, the JSON format might be better.
|
||||||
You can open `.csv` files with a text editor, such as Notepad, or a spreadsheet app, like Microsoft Excel and Google Sheets.
|
You can open `.csv` files with a text editor, such as Notepad, or a spreadsheet app, like Microsoft Excel and Google Sheets.
|
||||||
|
|
||||||
**([Back to top](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#getting-started))**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Further reading: [.NET date formats](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings)
|
|
||||||
Special thanks to [@Yudi](https://github.com/Yudi)
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
# Linux usage instructions
|
|
||||||
|
|
||||||
## Installing .NET Runtime
|
|
||||||
|
|
||||||
Please follow the [instructions provided here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md).
|
|
||||||
|
|
||||||
## Downloading and using DiscordChatExporter.Cli
|
|
||||||
|
|
||||||
1. Download [DiscordChatExporter.CLI.zip](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest) and extract it to a folder.
|
|
||||||
2. Open Terminal.
|
|
||||||
3. `cd` into the extracted folder. You can do this in Terminal by typing `cd`, then press the SPACE key, drag and drop the extracted folder into the Terminal window, and press the ENTER key.
|
|
||||||
4. Replace `TOKEN` and `CHANNEL`, then execute this command to export:
|
|
||||||
|
|
||||||
```
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t TOKEN -c CHANNEL
|
|
||||||
```
|
|
||||||
|
|
||||||
> [How to get Token and Channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
|
||||||
|
|
||||||
There's much more you can do with DCE.CLI! Read the [CLI explained](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#dcecli-commands-) page to get started.
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# macOS usage instructions
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Installing .NET Runtime
|
|
||||||
|
|
||||||
Please follow the [instructions provided here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md).
|
|
||||||
|
|
||||||
## Downloading and using DiscordChatExporter.Cli
|
|
||||||
|
|
||||||
1. Download [DiscordChatExporter.CLI.zip](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest) and extract it to a folder.
|
|
||||||
2. Search for `Terminal.app` in Spotlight (⌘+SPACE), then open it.
|
|
||||||
3. In the Terminal window, type `cd` , press the SPACE key, then drag and drop the extracted folder into the window, then press the RETURN key.
|
|
||||||
4. Execute the following command to export, replacing `TOKEN` and `CHANNEL` with your own values:
|
|
||||||
|
|
||||||
```
|
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t TOKEN -c CHANNEL
|
|
||||||
```
|
|
||||||
|
|
||||||
> [How to get Token and Channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
|
||||||
|
|
||||||
There's much more you can do with DCE.CLI! Read the [CLI explained](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#dcecli-commands-) page to get started.
|
|
||||||
+29
-17
@@ -2,92 +2,104 @@
|
|||||||
|
|
||||||
You can use a special notation to filter messages that you want to have included in an export. The notation syntax is designed to mimic Discord's search query syntax, but with additional capabilities.
|
You can use a special notation to filter messages that you want to have included in an export. The notation syntax is designed to mimic Discord's search query syntax, but with additional capabilities.
|
||||||
|
|
||||||
To configure a filter, specify it in advanced export parameters when using the GUI or by passing the `--filter` option when using the CLI.
|
To configure a filter, specify it in advanced export parameters when using the GUI or by passing the `--filter` option when using the CLI. For the CLI version, see also [caveats](#cli-caveats).
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
- Filter by user
|
- Filter by user
|
||||||
|
|
||||||
```
|
```console
|
||||||
from:Tyrrrz
|
from:Tyrrrz
|
||||||
```
|
```
|
||||||
|
|
||||||
- Filter by user (with discriminator)
|
- Filter by user (with discriminator)
|
||||||
|
|
||||||
```
|
```console
|
||||||
from:Tyrrrz#1234
|
from:Tyrrrz#1234
|
||||||
```
|
```
|
||||||
|
|
||||||
- Filter by message content (allowed values: `link`, `embed`, `file`, `video`, `image`, `sound`)
|
- Filter by message content (allowed values: `link`, `embed`, `file`, `video`, `image`, `sound`)
|
||||||
|
|
||||||
```
|
```console
|
||||||
has:image
|
has:image
|
||||||
```
|
```
|
||||||
|
|
||||||
- Filter by mentioned user (same rules apply as with `from:` filter)
|
- Filter by mentioned user (same rules apply as with `from:` filter)
|
||||||
|
|
||||||
```
|
```console
|
||||||
mentions:Tyrrrz#1234
|
mentions:Tyrrrz#1234
|
||||||
```
|
```
|
||||||
|
|
||||||
- Filter by contained text (has word "hello" and word "world" somewhere in the message text):
|
- Filter by contained text (has word "hello" and word "world" somewhere in the message text):
|
||||||
|
|
||||||
```
|
```console
|
||||||
hello world
|
hello world
|
||||||
```
|
```
|
||||||
|
|
||||||
- Filter by contained text (has the string "hello world" somewhere in the message text):
|
- Filter by contained text (has the string "hello world" somewhere in the message text):
|
||||||
|
|
||||||
```
|
```console
|
||||||
"hello world"
|
"hello world"
|
||||||
```
|
```
|
||||||
|
|
||||||
- Combine multiple filters ('and'):
|
- Combine multiple filters ('and'):
|
||||||
|
|
||||||
```
|
```console
|
||||||
from:Tyrrrz has:image
|
from:Tyrrrz has:image
|
||||||
```
|
```
|
||||||
|
|
||||||
- Same thing but with an explicit operator:
|
- Same thing but with an explicit operator:
|
||||||
|
|
||||||
```
|
```console
|
||||||
from:Tyrrrz & has:image
|
from:Tyrrrz & has:image
|
||||||
```
|
```
|
||||||
|
|
||||||
- Combine multiple filters ('or'):
|
- Combine multiple filters ('or'):
|
||||||
|
|
||||||
```
|
```console
|
||||||
from:Tyrrrz | from:"96-LB"
|
from:Tyrrrz | from:"96-LB"
|
||||||
```
|
```
|
||||||
|
|
||||||
- Combine multiple filters using groups:
|
- Combine multiple filters using groups:
|
||||||
|
|
||||||
```
|
```console
|
||||||
(from:Tyrrrz | from:"96-LB") has:image
|
(from:Tyrrrz | from:"96-LB") has:image
|
||||||
```
|
```
|
||||||
|
|
||||||
- Negate a filter:
|
- Negate a filter:
|
||||||
|
|
||||||
```
|
```console
|
||||||
-from:Tyrrrz | -has:image
|
-from:Tyrrrz | -has:image
|
||||||
```
|
```
|
||||||
|
|
||||||
- Negate a grouped filter:
|
- Negate a grouped filter:
|
||||||
|
|
||||||
```
|
```console
|
||||||
-(from:Tyrrrz has:image)
|
-(from:Tyrrrz has:image)
|
||||||
```
|
```
|
||||||
|
|
||||||
- Escape special characters (`-` is escaped below, so it's not parsed as negation operator):
|
- Escape special characters (`-` is escaped below, so it's not parsed as negation operator):
|
||||||
|
|
||||||
```
|
```console
|
||||||
from:96\-LB
|
from:96\-LB
|
||||||
```
|
```
|
||||||
|
|
||||||
## CLI Caveat
|
## CLI Caveats
|
||||||
|
|
||||||
Negated filters (those that start with `-`) may cause parsing issues when using the CLI version of DiscordChatExporter. To avoid this, use the tilde (`~`) character instead of the dash (`-`):
|
In most cases, you will need to enclose your filter in quotes (`"`) to escape characters that may have special meaning in your shell:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export [...] --filter "from:Tyrrrz has:image"
|
||||||
```
|
```
|
||||||
DiscordChatExporter.Cli export [...] --filter ~from:Tyrrrz
|
|
||||||
|
If you need to include quotes inside the filter itself as well, use single quotes (`'`) for those instead:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export [...] --filter "from:Tyrrrz 'hello world'"
|
||||||
|
```
|
||||||
|
|
||||||
|
Additionally, negated filters (those that start with `-`) may cause parsing issues even when enclosed in quotes. To avoid this, use the tilde (`~`) character instead of the dash (`-`):
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export [...] --filter ~from:Tyrrrz
|
||||||
```
|
```
|
||||||
|
|||||||
+15
-16
@@ -2,21 +2,20 @@
|
|||||||
|
|
||||||
## Installation & Usage
|
## Installation & Usage
|
||||||
|
|
||||||
- [Get .NET Core Runtime](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md) (Required for CLI; Installed automatically for GUI; Not required in Docker)
|
- [Get .NET Runtime](Dotnet.md)
|
||||||
- [Windows](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#gui-or-cli) | [macOS](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/MacOS.md) | [Linux](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Linux.md) | [Docker](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md)
|
|
||||||
- Getting started:
|
- Getting started:
|
||||||
- [Using the GUI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#using-the-gui)
|
- [Using the GUI](Using-the-GUI.md)
|
||||||
- [Using the CLI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#using-the-cli)
|
- [Using the CLI](Using-the-CLI.md)
|
||||||
- [File formats](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#file-formats)
|
- [File formats](Getting-started.md#file-formats)
|
||||||
|
|
||||||
## Guides
|
## Guides
|
||||||
|
|
||||||
- [How to get Token and Channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
- [How to get Token and Channel IDs](Token-and-IDs.md)
|
||||||
- [How to use message filters](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Message-filters.md)
|
- [How to use message filters](Message-filters.md)
|
||||||
- Export scheduling with CLI:
|
- Export scheduling with CLI:
|
||||||
- [Windows](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-windows.md)
|
- [Windows](Scheduling-Windows.md)
|
||||||
- [macOS](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-MacOS.md)
|
- [macOS](Scheduling-MacOS.md)
|
||||||
- [Linux](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-Linux.md)
|
- [Linux](Scheduling-Linux.md)
|
||||||
|
|
||||||
## Video tutorial
|
## Video tutorial
|
||||||
|
|
||||||
@@ -26,9 +25,9 @@
|
|||||||
|
|
||||||
## FAQ & Troubleshooting
|
## FAQ & Troubleshooting
|
||||||
|
|
||||||
- [General questions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#general)
|
- [General questions](Troubleshooting.md#general)
|
||||||
- [First steps help](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#first-steps)
|
- [First steps help](Troubleshooting.md#first-steps)
|
||||||
- [It's crashing/failing](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#DCE-is-crashingfailing)
|
- [It's crashing/failing](Troubleshooting.md#DCE-is-crashingfailing)
|
||||||
- [.NET Core Runtime is required](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#net-core-runtime-is-required)
|
- [.NET Core Runtime is required](Troubleshooting.md#net-core-runtime-is-required)
|
||||||
- [Errors](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md#errors)
|
- [Errors](Troubleshooting.md#errors)
|
||||||
- [**More help**](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Troubleshooting.md)
|
- [**More help**](Troubleshooting.md)
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
# Scheduling exports with Cron
|
# Scheduling exports with Cron
|
||||||
|
|
||||||
Make sure you already have **DiscordChatExporter.CLI** and **.NET Core** properly installed ([instructions here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Linux.md)).
|
Make sure you already have **DiscordChatExporter.CLI** downloaded and **.NET Runtime** installed.
|
||||||
|
|
||||||
You can use Cron on macOS, but [this method](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-MacOS.md) is preferred.
|
## Creating the script
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
1. Open Terminal and create a new text file with `nano /path/to/DiscordChatExporter/cron.sh`
|
1. Open Terminal and create a new text file with `nano /path/to/DiscordChatExporter/cron.sh`
|
||||||
|
|
||||||
@@ -47,7 +45,7 @@ fi
|
|||||||
cd $DLLFOLDER || exit 1
|
cd $DLLFOLDER || exit 1
|
||||||
|
|
||||||
# This will export your chat
|
# This will export your chat
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t $TOKEN -c $CHANNELID -f $EXPORTFORMAT -o $FILENAME.tmp
|
./DiscordChatExporter.Cli export -t $TOKEN -c $CHANNELID -f $EXPORTFORMAT -o $FILENAME.tmp
|
||||||
|
|
||||||
# This sets the current time to a variable
|
# This sets the current time to a variable
|
||||||
CURRENTTIME=$(date +"%Y-%m-%d-%H-%M-%S")
|
CURRENTTIME=$(date +"%Y-%m-%d-%H-%M-%S")
|
||||||
@@ -66,8 +64,8 @@ exit 0
|
|||||||
|
|
||||||
3. Replace:
|
3. Replace:
|
||||||
|
|
||||||
- `tokenhere` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
- `tokenhere` with your [Token](Token-and-IDs.md).
|
||||||
- `channelhere` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
- `channelhere` with a [Channel ID](Token-and-IDs.md).
|
||||||
- `dceFOLDERpathhere` with DCE's **directory path** (e.g. `/path/to/folder`, NOT `/path/to/folder/DiscordChatExporter.dll`).
|
- `dceFOLDERpathhere` with DCE's **directory path** (e.g. `/path/to/folder`, NOT `/path/to/folder/DiscordChatExporter.dll`).
|
||||||
- `filenamehere` with the exported channel's filename, without spaces.
|
- `filenamehere` with the exported channel's filename, without spaces.
|
||||||
- `dirhere` with the export directory (e.g. /home/user/Documents/Discord\ Exports).
|
- `dirhere` with the export directory (e.g. /home/user/Documents/Discord\ Exports).
|
||||||
@@ -108,7 +106,7 @@ Verify your cron time [here](https://crontab.guru).
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Extra information**
|
**Additional information**
|
||||||
|
|
||||||
The week starts on Sunday. 0 = SUN, 1 = MON ... 7 = SUN.
|
The week starts on Sunday. 0 = SUN, 1 = MON ... 7 = SUN.
|
||||||
|
|
||||||
|
|||||||
+43
-45
@@ -1,8 +1,6 @@
|
|||||||
# Scheduling exports on macOS
|
# Scheduling exports on macOS
|
||||||
|
|
||||||
Scheduling on macOS is a bit tricky, but it should work if you follow the instructions accordingly.
|
Make sure you already have **DiscordChatExporter.CLI** downloaded and **.NET Runtime** installed.
|
||||||
|
|
||||||
Make sure you already have **DiscordChatExporter.CLI** and **.NET Core** properly installed ([instructions here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/macOS-usage-instructions.md)).
|
|
||||||
|
|
||||||
## Creating the script
|
## Creating the script
|
||||||
|
|
||||||
@@ -51,7 +49,7 @@ fi
|
|||||||
cd $DLLFOLDER || exit 1
|
cd $DLLFOLDER || exit 1
|
||||||
|
|
||||||
# This will export your chat
|
# This will export your chat
|
||||||
dotnet DiscordChatExporter.Cli.dll export -t $TOKEN -c $CHANNELID -f $EXPORTFORMAT -o $FILENAME.tmp
|
./DiscordChatExporter.Cli export -t $TOKEN -c $CHANNELID -f $EXPORTFORMAT -o $FILENAME.tmp
|
||||||
|
|
||||||
# This sets the current time to a variable
|
# This sets the current time to a variable
|
||||||
CURRENTTIME=$(date +"%Y-%m-%d-%H-%M-%S")
|
CURRENTTIME=$(date +"%Y-%m-%d-%H-%M-%S")
|
||||||
@@ -70,8 +68,8 @@ exit 0
|
|||||||
|
|
||||||
4. Replace:
|
4. Replace:
|
||||||
|
|
||||||
- `tokenhere` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
- `tokenhere` with your [Token](Token-and-IDs.md)
|
||||||
- `channelhere` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
- `channelhere` with a [Channel ID](Token-and-IDs.md)
|
||||||
- `dceFOLDERpathhere` with DCE's **directory's path** (e.g. `/Users/user/Desktop/DiscordChatExporterFolder`, NOT `/Users/user/Desktop/DiscordChatExporterFolder/DiscordChatExporter.DLL`)
|
- `dceFOLDERpathhere` with DCE's **directory's path** (e.g. `/Users/user/Desktop/DiscordChatExporterFolder`, NOT `/Users/user/Desktop/DiscordChatExporterFolder/DiscordChatExporter.DLL`)
|
||||||
- `filenamehere` with the exported channel's filename, without spaces
|
- `filenamehere` with the exported channel's filename, without spaces
|
||||||
- `dirhere` with the directory you want the files to be saved at (e.g. `/Users/user/Documents/Discord\ Exports`)
|
- `dirhere` with the directory you want the files to be saved at (e.g. `/Users/user/Documents/Discord\ Exports`)
|
||||||
@@ -88,7 +86,7 @@ After copying and pasting, make sure the file/folder name is not missing. If a f
|
|||||||
- `/Users/user/Documents/Discord\ Exports` - Correct ✓
|
- `/Users/user/Documents/Discord\ Exports` - Correct ✓
|
||||||
- `/Users/user/Desktop/DiscordChatExporter` - Correct ✓
|
- `/Users/user/Desktop/DiscordChatExporter` - Correct ✓
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
5. Save the file as `filename.sh`, not `.txt`
|
5. Save the file as `filename.sh`, not `.txt`
|
||||||
6. Open Terminal.app, type `chmod +x`, press the SPACE key, then drag & drop the `filename.sh` into the Terminal window and hit RETURN. You may be prompted for your password, and you won't be able to see it as you type.
|
6. Open Terminal.app, type `chmod +x`, press the SPACE key, then drag & drop the `filename.sh` into the Terminal window and hit RETURN. You may be prompted for your password, and you won't be able to see it as you type.
|
||||||
@@ -101,13 +99,13 @@ Open TextEdit, make a Plain Text (⇧⌘T) and then paste the following into it:
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>local.discordchatexporter</string>
|
<string>local.discordchatexporter</string>
|
||||||
<key>Program</key>
|
<key>Program</key>
|
||||||
<string>/path/to/filename.sh</string>
|
<string>/path/to/filename.sh</string>
|
||||||
REPLACEME
|
REPLACEME
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -138,16 +136,16 @@ The following example is to export every 3600 seconds (1 hour), replace the inte
|
|||||||
```xml
|
```xml
|
||||||
<key>StartCalendarInterval</key>
|
<key>StartCalendarInterval</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Weekday</key>
|
<key>Weekday</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>Month</key>
|
<key>Month</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>Day</key>
|
<key>Day</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>Hour</key>
|
<key>Hour</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>Minute</key>
|
<key>Minute</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -168,17 +166,17 @@ Omitted keys are interpreted as wildcards, for example, if you delete the Minute
|
|||||||
|
|
||||||
Be aware that if you set the day to '31', the script will only run on months that have the 31st day.
|
Be aware that if you set the day to '31', the script will only run on months that have the 31st day.
|
||||||
|
|
||||||
**Check the examples below ([or skip to step 3 (loading the file)](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-MacOS.md#3-loading-the-plist-into-launchctl)):**
|
**Check the examples below ([or skip to step 3 (loading the file)](#3-loading-the-plist-into-launchctl)):**
|
||||||
|
|
||||||
Export everyday at 5:15 PM:
|
Export everyday at 5:15 PM:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<key>StartCalendarInterval</key>
|
<key>StartCalendarInterval</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Hour</key>
|
<key>Hour</key>
|
||||||
<integer>17</integer>
|
<integer>17</integer>
|
||||||
<key>Minute</key>
|
<key>Minute</key>
|
||||||
<integer>15</integer>
|
<integer>15</integer>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -188,8 +186,8 @@ Every 15 minutes of an hour (xx:15):
|
|||||||
```xml
|
```xml
|
||||||
<key>StartCalendarInterval</key>
|
<key>StartCalendarInterval</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Minute</key>
|
<key>Minute</key>
|
||||||
<integer>15</integer>
|
<integer>15</integer>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -199,20 +197,20 @@ Every Sunday at midnight and every Wednesday full hour (xx:00). Notice the inclu
|
|||||||
```xml
|
```xml
|
||||||
<key>StartCalendarInterval</key>
|
<key>StartCalendarInterval</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Weekday</key>
|
<key>Weekday</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>Hour</key>
|
<key>Hour</key>
|
||||||
<integer>00</integer>
|
<integer>00</integer>
|
||||||
<key>Minute</key>
|
<key>Minute</key>
|
||||||
<integer>00</integer>
|
<integer>00</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Weekday</key>
|
<key>Weekday</key>
|
||||||
<integer>3</integer>
|
<integer>3</integer>
|
||||||
<key>Minute</key>
|
<key>Minute</key>
|
||||||
<integer>00</integer>
|
<integer>00</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
# Scheduling exports on Windows
|
# Scheduling exports on Windows
|
||||||
|
|
||||||
We'll be using [DiscordChatExporter CLI](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest), PowerShell, and Task Scheduler.
|
We'll be using [DiscordChatExporter CLI](https://github.com/Tyrrrz/DiscordChatExporter/releases/latest), PowerShell, and Task Scheduler.
|
||||||
|
Make sure you already have **DiscordChatExporter.CLI** downloaded and **.NET Runtime** installed.
|
||||||
|
|
||||||
|
## Creating the script
|
||||||
|
|
||||||
1. Open a text editor such as Notepad and paste:
|
1. Open a text editor such as Notepad and paste:
|
||||||
|
|
||||||
```powershell
|
```console
|
||||||
# Info: https://github.com/Tyrrrz/DiscordChatExporter/wiki
|
# Info: https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs
|
||||||
|
|
||||||
$TOKEN = "tokenhere"
|
$TOKEN = "tokenhere"
|
||||||
$CHANNEL = "channelhere"
|
$CHANNEL = "channelhere"
|
||||||
@@ -17,7 +20,7 @@ $EXPORTFORMAT = "formathere"
|
|||||||
|
|
||||||
cd $EXEPATH
|
cd $EXEPATH
|
||||||
|
|
||||||
.\DiscordChatExporter.Cli.exe export -t $TOKEN -c $CHANNEL -f $EXPORTFORMAT -o "$FILENAME.tmp"
|
./DiscordChatExporter.Cli export -t $TOKEN -c $CHANNEL -f $EXPORTFORMAT -o "$FILENAME.tmp"
|
||||||
|
|
||||||
$Date = Get-Date -Format "yyyy-MM-dd-HH-mm"
|
$Date = Get-Date -Format "yyyy-MM-dd-HH-mm"
|
||||||
|
|
||||||
@@ -31,8 +34,8 @@ exit
|
|||||||
|
|
||||||
2. Replace:
|
2. Replace:
|
||||||
|
|
||||||
- `tokenhere` with your [Token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
- `tokenhere` with your [Token](Token-and-IDs.md)
|
||||||
- `channelhere` with a [Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
- `channelhere` with a [Channel ID](Token-and-IDs.md)
|
||||||
- `exefolderhere` with the .exe **directory's path** (e.g. C:\Users\User\Desktop\DiscordChatExporter)
|
- `exefolderhere` with the .exe **directory's path** (e.g. C:\Users\User\Desktop\DiscordChatExporter)
|
||||||
- `filenamehere` with a filename without spaces
|
- `filenamehere` with a filename without spaces
|
||||||
- `dirhere` with the export directory (e.g. C:\Users\User\Documents\Exports)
|
- `dirhere` with the export directory (e.g. C:\Users\User\Documents\Exports)
|
||||||
@@ -40,7 +43,9 @@ exit
|
|||||||
|
|
||||||
Make sure not to delete the quotes (")
|
Make sure not to delete the quotes (")
|
||||||
|
|
||||||
3. Save the file as `filename.ps1` not `.txt`
|
3. Save the file as `filename.ps1`, not as `.txt`
|
||||||
|
|
||||||
|
> **Note**: You can also modify the script to use other options, such as `include-threads` or switch to a different command, e. g. `exportguild`.
|
||||||
|
|
||||||
## Export at Startup
|
## Export at Startup
|
||||||
|
|
||||||
@@ -49,14 +54,14 @@ Make sure not to delete the quotes (")
|
|||||||
|
|
||||||
## Scheduling with Task Scheduler
|
## Scheduling with Task Scheduler
|
||||||
|
|
||||||
Please notice your computer must be turned on so the exportation can occur.
|
Please note that your computer must be turned on for the export to happen.
|
||||||
|
|
||||||
1. Press Windows + R, type `taskschd.msc` and press ENTER
|
1. Press Windows + R, type `taskschd.msc` and press ENTER
|
||||||
2. Select `Task Scheduler Library`, create a Basic Task, and follow the instructions on-screen
|
2. Select `Task Scheduler Library`, create a Basic Task, and follow the instructions on-screen
|
||||||
|
|
||||||
<img src="https://i.imgur.com/MHRVGDi.png" height="500"/>
|
<img src="https://i.imgur.com/MHRVGDi.png" height="500"/>
|
||||||
|
|
||||||
[  ](https://i.imgur.com/3gHkF0t.png)
|

|
||||||
|
|
||||||
3. At 'Start a Program', write `powershell -file -ExecutionPolicy ByPass -WindowStyle Hidden "C:\path\to\filename.ps1"` in the Program/script text box
|
3. At 'Start a Program', write `powershell -file -ExecutionPolicy ByPass -WindowStyle Hidden "C:\path\to\filename.ps1"` in the Program/script text box
|
||||||
|
|
||||||
|
|||||||
+43
-29
@@ -14,6 +14,23 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
|||||||
|
|
||||||
#### In Chrome
|
#### In Chrome
|
||||||
|
|
||||||
|
##### Using the console
|
||||||
|
|
||||||
|
1. <img width="500" align="right" src="https://i.imgur.com/zdDwIT5.jpg" />Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> (<kbd>⌥</kbd>+<kbd>⌘</kbd>+<kbd>I</kbd> on macOS). Chrome's [DevTools](https://developer.chrome.com/docs/devtools/overview) tools will display.
|
||||||
|
|
||||||
|
<br clear="right" />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
2. Click the `Console` tab. The [console](https://developer.chrome.com/docs/devtools/console/) will open.
|
||||||
|
|
||||||
|
3. Type
|
||||||
|
|
||||||
|
```js
|
||||||
|
(webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken()
|
||||||
|
```
|
||||||
|
|
||||||
|
into the console and press <kbd>Enter</kbd>. The console will display your user token.
|
||||||
|
|
||||||
##### Using the network monitor
|
##### Using the network monitor
|
||||||
|
|
||||||
1. <img width="500" align="right" src="https://i.imgur.com/zdDwIT5.jpg" />Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> (<kbd>⌥</kbd>+<kbd>⌘</kbd>+<kbd>I</kbd> on macOS). Chrome's [DevTools](https://developer.chrome.com/docs/devtools/overview) tools will display.
|
1. <img width="500" align="right" src="https://i.imgur.com/zdDwIT5.jpg" />Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> (<kbd>⌥</kbd>+<kbd>⌘</kbd>+<kbd>I</kbd> on macOS). Chrome's [DevTools](https://developer.chrome.com/docs/devtools/overview) tools will display.
|
||||||
@@ -31,12 +48,12 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
|||||||
<br clear="right" />
|
<br clear="right" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
4. <img width="500" align="right" src="https://i.imgur.com/rnZG8Id.png" />Click the text box labelled `Filter` and type `library`. The entries will filter down to a single entry named `library`.
|
4. <img width="500" align="right" src="https://i.imgur.com/rnZG8Id.png" />Click the text box labelled `Filter` and type `messages`. The entries will filter down to a single request named `messages`. If the request doesn't appear, switch to any other Discord channel to trigger it.
|
||||||
|
|
||||||
<br clear="right" />
|
<br clear="right" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
5. <img width="500" align="right" src="https://i.imgur.com/29dE3fR.png" />Click the entry named `library`. A panel will open to the right and display details about the entry. Click the `Headers` tab if it isn't already active.
|
5. <img width="500" align="right" src="https://i.imgur.com/29dE3fR.png" />Click the entry named `messages`. A panel will open to the right and display details about the entry. Click the `Headers` tab if it isn't already active.
|
||||||
|
|
||||||
<br clear="right" />
|
<br clear="right" />
|
||||||
<br />
|
<br />
|
||||||
@@ -90,6 +107,23 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
|||||||
|
|
||||||
#### In Firefox
|
#### In Firefox
|
||||||
|
|
||||||
|
##### Using the console
|
||||||
|
|
||||||
|
1. <img width="500" align="right" src="https://i.imgur.com/O34nwdG.png" />Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>K</kbd> (<kbd>⌥</kbd>+<kbd>⌘</kbd>+<kbd>K</kbd> on macOS). Firefox’s [web developer tools](https://firefox-source-docs.mozilla.org/devtools-user/) will display at the bottom of the window, and the [web console](https://firefox-source-docs.mozilla.org/devtools-user/console/index.html) will display.
|
||||||
|
|
||||||
|
<br clear="right" />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
2. Click the `Console` tab. The [console](https://firefox-source-docs.mozilla.org/devtools-user/console/index.html) will open.
|
||||||
|
|
||||||
|
1. Type
|
||||||
|
|
||||||
|
```js
|
||||||
|
(webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken()
|
||||||
|
```
|
||||||
|
|
||||||
|
into the console and press <kbd>Enter</kbd>. The console will display your user token.
|
||||||
|
|
||||||
##### Using the network monitor
|
##### Using the network monitor
|
||||||
|
|
||||||
1. <img width="500" align="right" src="https://i.imgur.com/O34nwdG.png" />Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>E</kbd> (<kbd>⌥</kbd>+<kbd>⌘</kbd>+<kbd>E</kbd> on macOS). Firefox’s [web developer tools](https://firefox-source-docs.mozilla.org/devtools-user/) will display at the bottom of the window, and the [network monitor](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/) will display.
|
1. <img width="500" align="right" src="https://i.imgur.com/O34nwdG.png" />Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>E</kbd> (<kbd>⌥</kbd>+<kbd>⌘</kbd>+<kbd>E</kbd> on macOS). Firefox’s [web developer tools](https://firefox-source-docs.mozilla.org/devtools-user/) will display at the bottom of the window, and the [network monitor](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/) will display.
|
||||||
@@ -102,12 +136,12 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
|||||||
<br clear="right" />
|
<br clear="right" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
3. <img width="500" align="right" src="https://i.imgur.com/efUCfBO.png" />Type `library` into the filter. The network request list will filter out any entries not containing the string `library`.
|
3. <img width="500" align="right" src="https://i.imgur.com/efUCfBO.png" />Type `messages` into the filter. The network request list will filter out any entries not containing the string `messages`. If the request doesn't appear, switch to any other Discord channel to trigger it.
|
||||||
|
|
||||||
<br clear="right" />
|
<br clear="right" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
4. <img width="500" align="right" src="https://i.imgur.com/cdJZ7Q1.png" />Click `library`. The [network request details pane](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html) will display. The [headers tab](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html#network-monitor-request-details-headers-tab) should be active by default. If it isn’t, click it.
|
4. <img width="500" align="right" src="https://i.imgur.com/cdJZ7Q1.png" />Click `messages`. The [network request details pane](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html) will display. The [headers tab](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html#network-monitor-request-details-headers-tab) should be active by default. If it isn’t, click it.
|
||||||
|
|
||||||
<br clear="right" />
|
<br clear="right" />
|
||||||
<br />
|
<br />
|
||||||
@@ -164,7 +198,7 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
|||||||
<br clear="right" />
|
<br clear="right" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
### Through the desktop app / Enabling web developer tools
|
### Through the desktop app / enabling web developer tools
|
||||||
|
|
||||||
#### By editing the settings file
|
#### By editing the settings file
|
||||||
|
|
||||||
@@ -198,7 +232,7 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
|||||||
|
|
||||||
4. Launch Discord.
|
4. Launch Discord.
|
||||||
|
|
||||||
5. To find your user token, continue [here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#in-chrome).
|
5. To find your user token, continue [here](#in-chrome).
|
||||||
|
|
||||||
#### Via settings menu (BetterDiscord only)
|
#### Via settings menu (BetterDiscord only)
|
||||||
|
|
||||||
@@ -218,7 +252,7 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
|||||||
<br />
|
<br />
|
||||||
|
|
||||||
4. Press <kbd>Esc</kbd>. The settings page will close.
|
4. Press <kbd>Esc</kbd>. The settings page will close.
|
||||||
5. To find your user token, continue [here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#in-chrome).
|
5. To find your user token, continue [here](#in-chrome).
|
||||||
|
|
||||||
## How to get a Bot Token
|
## How to get a Bot Token
|
||||||
|
|
||||||
@@ -234,29 +268,9 @@ Prerequisite step: Navigate to [discord.com](https://discord.com) and login.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## How to get a Server ID or a Server Channel ID
|
## How to get a Server ID or a Channel ID
|
||||||
|
|
||||||
1. Open Discord Settings
|
1. Open Discord Settings
|
||||||
2. Go to the **Advanced** section
|
2. Go to the **Advanced** section
|
||||||
3. Enable **Developer Mode**
|
3. Enable **Developer Mode**
|
||||||
4. Right-click on the desired server or channel and click Copy ID
|
4. Right-click on the desired server or channel and click **Copy Server ID** or **Copy Channel ID**
|
||||||
|
|
||||||
## How to get a Direct Message Channel ID
|
|
||||||
|
|
||||||
1. Click the three dots next to any message in the channel you want to export.
|
|
||||||
2. Paste the link into a text editor.
|
|
||||||
3. Copy the text in the highlighted part of the link.
|
|
||||||
|
|
||||||
> E.g. in https꞉//discord.com/channels/@me/**189716987098470**/0985709387059874, you should copy **189716987098470**
|
|
||||||
|
|
||||||
Make sure you're not copying the user's ID.
|
|
||||||
|
|
||||||
**Alternatively, you can also:**
|
|
||||||
|
|
||||||
1. Open the desired direct message channel
|
|
||||||
2. Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> (<kbd>⌥</kbd>+<kbd>⌘</kbd>+<kbd>I</kbd> on macOS) on Discord to show developer tools
|
|
||||||
3. Navigate to the `Console` tab
|
|
||||||
4. Type `window.location.href` and press Enter
|
|
||||||
5. Copy the first long sequence of numbers inside the URL
|
|
||||||
|
|
||||||
> E.g. in https꞉//discord.com/channels/@me/**84289740160**, you should copy **84289740160**
|
|
||||||
|
|||||||
+36
-44
@@ -6,7 +6,7 @@ Here you'll find the answers to most of the questions related to **DiscordChatEx
|
|||||||
- ❓ If you still have unanswered questions _after_ reading this page, feel free to [create a new discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new).
|
- ❓ If you still have unanswered questions _after_ reading this page, feel free to [create a new discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new).
|
||||||
- 🐞 If you have encountered a problem that's not described here, has not [been discussed before](https://github.com/Tyrrrz/DiscordChatExporter/discussions), and is not a [known issue](https://github.com/Tyrrrz/DiscordChatExporter/issues?q=is%3Aissue), please [create a new discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new) or [open a bug report](https://github.com/Tyrrrz/DiscordChatExporter/issues/new). Don't forget to include your platform (Windows, Mac, Linux, etc.) and a detailed description of your question/problem.
|
- 🐞 If you have encountered a problem that's not described here, has not [been discussed before](https://github.com/Tyrrrz/DiscordChatExporter/discussions), and is not a [known issue](https://github.com/Tyrrrz/DiscordChatExporter/issues?q=is%3Aissue), please [create a new discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new) or [open a bug report](https://github.com/Tyrrrz/DiscordChatExporter/issues/new). Don't forget to include your platform (Windows, Mac, Linux, etc.) and a detailed description of your question/problem.
|
||||||
|
|
||||||
## General
|
## General questions
|
||||||
|
|
||||||
### Token stealer?
|
### Token stealer?
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ A token can be used to log into your account, so treat it like a password and ne
|
|||||||
|
|
||||||
### How can I reset my token?
|
### How can I reset my token?
|
||||||
|
|
||||||
Follow the [instructions here](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
Follow the [instructions here](Token-and-IDs.md).
|
||||||
|
|
||||||
### Will I get banned if I use this?
|
### Will I get banned if I use this?
|
||||||
|
|
||||||
@@ -46,6 +46,10 @@ Yes, and other media too. Export using the "Download media" (`--media`) option.
|
|||||||
|
|
||||||
Yes.
|
Yes.
|
||||||
|
|
||||||
|
### Can DCE export multiple formats at once?
|
||||||
|
|
||||||
|
No, you can only export one format at a time.
|
||||||
|
|
||||||
### Can DCE recreate the exported chats in Discord?
|
### Can DCE recreate the exported chats in Discord?
|
||||||
|
|
||||||
No, DCE is an exporter.
|
No, DCE is an exporter.
|
||||||
@@ -54,49 +58,45 @@ No, DCE is an exporter.
|
|||||||
|
|
||||||
No, DCE is an exporter.
|
No, DCE is an exporter.
|
||||||
|
|
||||||
|
### Can DCE add new messages to an existing export?
|
||||||
|
|
||||||
|
No.
|
||||||
|
|
||||||
## First steps
|
## First steps
|
||||||
|
|
||||||
### How can I find my token?
|
### How can I find my token?
|
||||||
|
|
||||||
Check the following page: [Obtaining token](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
Check the following page: [Obtaining token](Token-and-IDs.md)
|
||||||
|
|
||||||
### When I open DCE a black window pops up quickly or nothing shows up.
|
### When I open DCE a black window pops up quickly or nothing shows up
|
||||||
|
|
||||||
If you have [.NET Core Runtime correctly installed](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md), you might have downloaded DCE.CLI, try [downloading the GUI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#gui-or-cli) instead.
|
If you have [.NET Runtime correctly installed](Dotnet.md), you might have downloaded the CLI flavor, try [downloading the GUI](Getting-started.md#gui-or-cli) instead.
|
||||||
|
|
||||||
### I can't open DCE. It sends me to a Visual Studio webpage.
|
|
||||||
|
|
||||||
Check the following page:
|
|
||||||
[Installation and usage](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Readme.md#installation--usage)
|
|
||||||
|
|
||||||
### How do I run DCE on macOS or Linux?
|
|
||||||
|
|
||||||
Check the following pages:
|
|
||||||
|
|
||||||
- [macOS usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/MacOS.md)
|
|
||||||
- [Linux usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Linux.md)
|
|
||||||
|
|
||||||
### How can I set DCE to export automatically at certain times?
|
### How can I set DCE to export automatically at certain times?
|
||||||
|
|
||||||
Check the following pages to learn how to schedule **DiscordChatExporter.CLI** runs (advanced):
|
Check the following pages to learn how to schedule **DiscordChatExporter.CLI** runs (advanced):
|
||||||
|
|
||||||
- [Windows scheduling](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-windows.md)
|
- [Windows scheduling](Scheduling-Windows.md)
|
||||||
- [macOS scheduling](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-MacOS.md)
|
- [macOS scheduling](Scheduling-MacOS.md)
|
||||||
- [Linux scheduling](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/scheduling-Linux.md)
|
- [Linux scheduling](Scheduling-Linux.md)
|
||||||
|
|
||||||
### The exported file is too large, I can't open it!
|
### The exported file is too large, I can't open it
|
||||||
|
|
||||||
Try opening it with a different program, try partitioning or use a different file format, like `PlainText`.
|
Try opening it with a different program, try partitioning or use a different file format, like `PlainText`.
|
||||||
|
|
||||||
### DCE is crashing/failing.
|
### DCE is crashing/failing
|
||||||
|
|
||||||
Check the following page: [Installing .NET Core Runtime](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md)
|
Check the following page: [Installing .NET Core Runtime](Dotnet.md)
|
||||||
|
|
||||||
If you already have .NET Core installed, please check if your problem is a [known issue](https://github.com/Tyrrrz/DiscordChatExporter/issues?q=is%3Aissue) before [opening a bug report](https://github.com/Tyrrrz/DiscordChatExporter/issues/new).
|
If you already have .NET Core installed, please check if your problem is a [known issue](https://github.com/Tyrrrz/DiscordChatExporter/issues?q=is%3Aissue) before [opening a bug report](https://github.com/Tyrrrz/DiscordChatExporter/issues/new).
|
||||||
|
|
||||||
### .NET Core Runtime is required.
|
### .NET Core Runtime is required
|
||||||
|
|
||||||
Check the following page: [Installing .NET Core Runtime](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Dotnet.md)
|
Check the following page: [Installing .NET Core Runtime](Dotnet.md)
|
||||||
|
|
||||||
|
### I see messages in the export, but they have no content
|
||||||
|
|
||||||
|
Your bot is missing the 'Message Content Intent'. Go to the [Discord Developer Portal](https://discord.com/developers/applications), navigate to the 'Bot' section and enable it.
|
||||||
|
|
||||||
## CLI
|
## CLI
|
||||||
|
|
||||||
@@ -104,56 +104,48 @@ Check the following page: [Installing .NET Core Runtime](https://github.com/Tyrr
|
|||||||
|
|
||||||
Check the following page:
|
Check the following page:
|
||||||
|
|
||||||
- [Using the CLI](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Getting-started.md#using-the-cli)
|
- [Using the CLI](Using-the-CLI.md)
|
||||||
|
|
||||||
If you're using **Docker**, please refer to the [Docker Usage Instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Docker.md) instead.
|
If you're using **Docker**, please refer to the [Docker Usage Instructions](Docker.md) instead.
|
||||||
|
|
||||||
### Where can I find the 'Channel IDs'?
|
### Where can I find the 'Channel IDs'?
|
||||||
|
|
||||||
Check the following page:
|
Check the following page:
|
||||||
|
|
||||||
- [Obtaining Channel IDs](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md)
|
- [Obtaining Channel IDs](Token-and-IDs.md)
|
||||||
|
|
||||||
### I can't find Docker exported chats
|
### I can't find Docker exported chats
|
||||||
|
|
||||||
Check the following page:
|
Check the following page:
|
||||||
|
|
||||||
- [Docker usage instructions](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/docker)
|
- [Docker usage instructions](Docker.md)
|
||||||
|
|
||||||
### I can't export Direct Messages
|
### I can't export Direct Messages
|
||||||
|
|
||||||
Make sure you're [copying the DM Channel ID](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md#how-to-get-a-direct-message-channel-id), not the person's user ID.
|
Make sure you're [copying the DM Channel ID](Token-and-IDs.md#how-to-get-a-direct-message-channel-id), not the person's user ID.
|
||||||
|
|
||||||
## Errors
|
## Errors
|
||||||
|
|
||||||
```
|
```yml
|
||||||
DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Authentication token is invalid.
|
DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Authentication token is invalid.
|
||||||
...
|
|
||||||
```
|
```
|
||||||
|
|
||||||
↳ Make sure the provided token is correct.
|
↳ Make sure the provided token is correct.
|
||||||
|
|
||||||
```
|
```yml
|
||||||
DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Requested resource does not exist.
|
DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Requested resource does not exist.
|
||||||
```
|
```
|
||||||
|
|
||||||
↳ Check your channel ID, it might be invalid. [Read this if you need help](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Token-and-IDs.md).
|
↳ Check your channel ID, it might be invalid. [Read this if you need help](Token-and-IDs.md).
|
||||||
|
|
||||||
```
|
```yml
|
||||||
DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Access is forbidden.
|
DiscordChatExporter.Domain.Exceptions.DiscordChatExporterException: Access is forbidden.
|
||||||
```
|
```
|
||||||
|
|
||||||
↳ This means you don't have access to the channel.
|
↳ This means you don't have access to the channel.
|
||||||
|
|
||||||
```
|
```yml
|
||||||
The application to execute does not exist:
|
|
||||||
```
|
|
||||||
|
|
||||||
↳ The `DiscordChatExporter.Cli.dll` file is missing. Keep the `.exe` and all the `.dll` files together. If you didn't move the files, try unzipping again.
|
|
||||||
|
|
||||||
```
|
|
||||||
System.Net.WebException: Error: TrustFailure ... Invalid certificate received from server.
|
System.Net.WebException: Error: TrustFailure ... Invalid certificate received from server.
|
||||||
...
|
|
||||||
```
|
```
|
||||||
|
|
||||||
↳ Try running cert-sync.
|
↳ Try running cert-sync.
|
||||||
@@ -167,5 +159,5 @@ If it still doesn't work, try mozroots: `mozroots --import --ask-remove`
|
|||||||
---
|
---
|
||||||
|
|
||||||
> ❓ If you still have unanswered questions, feel free to [create a new discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new).
|
> ❓ If you still have unanswered questions, feel free to [create a new discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new).
|
||||||
|
>
|
||||||
> 🐞 If you have encountered a problem that's not described here, has not [been discussed before](https://github.com/Tyrrrz/DiscordChatExporter/discussions), and is not a [known issue](https://github.com/Tyrrrz/DiscordChatExporter/issues?q=is%3Aissue), please [create a new discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new) or [open a bug report](https://github.com/Tyrrrz/DiscordChatExporter/issues/new).
|
> 🐞 If you have encountered a problem that's not described here, has not [been discussed before](https://github.com/Tyrrrz/DiscordChatExporter/discussions), and is not a [known issue](https://github.com/Tyrrrz/DiscordChatExporter/issues?q=is%3Aissue), please [create a new discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new) or [open a bug report](https://github.com/Tyrrrz/DiscordChatExporter/issues/new).
|
||||||
|
|||||||
@@ -0,0 +1,286 @@
|
|||||||
|
# Using the CLI
|
||||||
|
|
||||||
|
## Guide
|
||||||
|
|
||||||
|
> **Note**:
|
||||||
|
> Make sure you have [.NET Core installed](Dotnet.md) before attempting to run the commands below.
|
||||||
|
> **Docker** users, please refer to the [Docker usage instructions](Docker.md).
|
||||||
|
|
||||||
|
## Step 1
|
||||||
|
|
||||||
|
After extracting the `.zip`, open Command Prompt, aka `cmd` (`Terminal` on **macOS** and **Linux**).
|
||||||
|
|
||||||
|
## Step 2
|
||||||
|
|
||||||
|
Change the current directory to DCE's folder with `cd C:\path\to\directory`, then press ENTER to run the command.
|
||||||
|
|
||||||
|
**Windows** users can quickly get the directory's path by clicking the address bar while inside the folder.
|
||||||
|

|
||||||
|
|
||||||
|
**macOS** users can select the `.exe`, hit Command+I (⌘I), and copy what's after `Where:` to get the directory
|
||||||
|

|
||||||
|
|
||||||
|
You can also drag and drop the folder on **every platform**.
|
||||||
|

|
||||||
|
|
||||||
|
## Step 3
|
||||||
|
|
||||||
|
Now we're ready to run the commands. The examples on this page follow the Windows file path format, change the file
|
||||||
|
paths according to your system.
|
||||||
|
|
||||||
|
Type the following command in your terminal of choice, then press ENTER to run it. This will list all available subcommands and options.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Docker** users, please refer to the [Docker usage instructions](Docker.md).
|
||||||
|
|
||||||
|
## CLI commands
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
|-------------------------|------------------------------------------------------|
|
||||||
|
| export | Exports a channel |
|
||||||
|
| exportdm | Exports all direct message channels |
|
||||||
|
| exportguild | Exports all channels within the specified server |
|
||||||
|
| exportall | Exports all accessible channels |
|
||||||
|
| channels | Outputs the list of channels in the given server |
|
||||||
|
| dm | Outputs the list of direct message channels |
|
||||||
|
| guilds | Outputs the list of accessible servers |
|
||||||
|
| guide | Explains how to obtain token, server, and channel ID |
|
||||||
|
|
||||||
|
To use the commands, you'll need a token. For the instructions on how to get a token, please refer to [this page](Token-and-IDs.md), or run `./DiscordChatExporter.Cli guide`.
|
||||||
|
|
||||||
|
To get help with a specific command, run:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli command --help
|
||||||
|
```
|
||||||
|
|
||||||
|
For example, to figure out how to use the `export` command, run:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export --help
|
||||||
|
```
|
||||||
|
|
||||||
|
## Export a specific channel
|
||||||
|
|
||||||
|
You can quickly export with DCE's default settings by using just `-t token` and `-c channelid`.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Changing the format
|
||||||
|
|
||||||
|
You can change the export format to `HtmlDark`, `HtmlLight`, `PlainText` `Json` or `Csv` with `-f format`. The default
|
||||||
|
format is `HtmlDark`.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 -f Json
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Changing the output filename
|
||||||
|
|
||||||
|
You can change the filename by using `-o name.ext`. e.g. for the `HTML` format:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 -o myserver.html
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Changing the output directory
|
||||||
|
|
||||||
|
You can change the export directory by using `-o` and providing a path that ends with a slash or does not have a file
|
||||||
|
extension.
|
||||||
|
If any of the folders in the path have a space in its name, escape them with quotes (").
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 -o "C:\Discord Exports"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Changing the filename and output directory
|
||||||
|
|
||||||
|
You can change both the filename and export directory by using `-o directory\name.ext`.
|
||||||
|
Note that the filename must have an extension, otherwise it will be considered a directory name.
|
||||||
|
If any of the folders in the path have a space in its name, escape them with quotes (").
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 -o "C:\Discord Exports\myserver.html"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Generating the filename and output directory dynamically
|
||||||
|
|
||||||
|
You can use template tokens to generate the output file path based on the server and channel metadata.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 -o "C:\Discord Exports\%G\%T\%C.html"
|
||||||
|
```
|
||||||
|
|
||||||
|
Assuming you are exporting a channel named `"my-channel"` in the `"Text channels"` category from a server
|
||||||
|
called `"My server"`, you will get the following output file
|
||||||
|
path: `C:\Discord Exports\My server\Text channels\my-channel.html`
|
||||||
|
|
||||||
|
Here is the full list of supported template tokens:
|
||||||
|
|
||||||
|
- `%g` - server ID
|
||||||
|
- `%G` - server name
|
||||||
|
- `%t` - category ID
|
||||||
|
- `%T` - category name
|
||||||
|
- `%c` - channel ID
|
||||||
|
- `%C` - channel name
|
||||||
|
- `%p` - channel position
|
||||||
|
- `%P` - category position
|
||||||
|
- `%a` - the "after" date
|
||||||
|
- `%b` - the "before" date
|
||||||
|
- `%%` - escapes `%`
|
||||||
|
|
||||||
|
#### Partitioning
|
||||||
|
|
||||||
|
You can use partitioning to split files after a given number of messages or file size.
|
||||||
|
For example, a channel with 36 messages set to be partitioned every 10 messages will output 4 files.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 -p 10
|
||||||
|
```
|
||||||
|
|
||||||
|
A 45 MB channel set to be partitioned every 20 MB will output 3 files.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 -p 20mb
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Downloading assets
|
||||||
|
|
||||||
|
If this option is set, the export will include additional files such as user avatars, attached files, images, etc.
|
||||||
|
Only files that are referenced by the export are downloaded, which means that, for example, user avatars will not be
|
||||||
|
downloaded when using the plain text (TXT) export format.
|
||||||
|
A folder containing the assets will be created along with the exported chat. They must be kept together.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 --media
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Reusing assets
|
||||||
|
|
||||||
|
Previously downloaded assets can be reused to skip redundant downloads as long as the chat is always exported to the
|
||||||
|
same folder. Using this option can speed up future exports. This option requires the `--media` option.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 --media --reuse-media
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Changing the media directory
|
||||||
|
|
||||||
|
By default, the media directory is created alongside the exported chat. You can change this by using `--media-dir` and
|
||||||
|
providing a path that ends with a slash. All of the exported media will be stored in this directory.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 --media --media-dir "C:\Discord Media"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Changing the date format
|
||||||
|
|
||||||
|
You can customize how dates are formatted in the exported files by using `--locale` and inserting one of Discord's
|
||||||
|
locales. The default locale is `en-US`.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 --locale "de-DE"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Date ranges
|
||||||
|
|
||||||
|
**Messages sent before a date**
|
||||||
|
Use `--before` to export messages sent before the provided date. E.g. messages sent before September 18th, 2019:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 --before 2019-09-18
|
||||||
|
```
|
||||||
|
|
||||||
|
**Messages sent after a date**
|
||||||
|
Use `--after` to export messages sent after the provided date. E.g. messages sent after September 17th, 2019 11:34 PM:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 --after "2019-09-17 23:34"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Messages sent in a date range**
|
||||||
|
Use `--before` and `--after` to export messages sent during the provided date range. E.g. messages sent between
|
||||||
|
September 17th, 2019 11:34 PM and September 18th:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli export -t "mfa.Ifrn" -c 53555 --after "2019-09-17 23:34" --before "2019-09-18"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can try different formats like `17-SEP-2019 11:34 PM` or even refine your ranges down to
|
||||||
|
milliseconds `17-SEP-2019 23:45:30.6170`!
|
||||||
|
Don't forget to quote (") the date if it has spaces!
|
||||||
|
More info about .NET date
|
||||||
|
formats [here](https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings).
|
||||||
|
|
||||||
|
### Export channels from a specific server
|
||||||
|
|
||||||
|
To export all channels in a specific server, use the `exportguild` command and provide the server ID through the `-g|--guild` option:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli exportguild -t "mfa.Ifrn" -g 21814
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Including threads
|
||||||
|
|
||||||
|
By default, threads are not included in the export. You can change this behavior by using `--include-threads` and
|
||||||
|
specifying which threads should be included. It has possible values of `none`, `active`, or `all`, indicating which
|
||||||
|
threads should be included. To include both active and archived threads, use `--include-threads all`.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli exportguild -t "mfa.Ifrn" -g 21814 --include-threads all
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Including voice channels
|
||||||
|
|
||||||
|
By default, voice channels are included in the export. You can change this behavior by using `--include-vc` and
|
||||||
|
specifying whether to include voice channels in the export. It has possible values of `true` or `false`, to exclude
|
||||||
|
voice channels, use `--include-vc false`.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli exportguild -t "mfa.Ifrn" -g 21814 --include-vc false
|
||||||
|
```
|
||||||
|
|
||||||
|
### Export all channels
|
||||||
|
|
||||||
|
To export all accessible channels, use the `exportall` command:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli exportall -t "mfa.Ifrn"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Excluding DMs
|
||||||
|
|
||||||
|
To exclude DMs, add the `--include-dm false` option.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli exportall -t "mfa.Ifrn" --include-dm false
|
||||||
|
```
|
||||||
|
|
||||||
|
### List channels in a server
|
||||||
|
|
||||||
|
To list the channels available in a specific server, use the `channels` command and provide the server ID through the `-g|--guild` option:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli channels -t "mfa.Ifrn" -g 21814
|
||||||
|
```
|
||||||
|
|
||||||
|
### List direct message channels
|
||||||
|
|
||||||
|
To list all DM channels accessible to the current account, use the `dm` command:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli dm -t "mfa.Ifrn"
|
||||||
|
```
|
||||||
|
|
||||||
|
### List servers
|
||||||
|
|
||||||
|
To list all servers accessible by the current account, use the `guilds` command:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./DiscordChatExporter.Cli guilds -t "mfa.Ifrn" > C:\path\to\output.txt
|
||||||
|
```
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
# Using the GUI
|
||||||
|
|
||||||
|
## Video tutorial
|
||||||
|
|
||||||
|
[](https://youtube.com/watch?v=jjtu0VQXV7I)
|
||||||
|
|
||||||
|
> Video by [NoIntro Tutorials](https://youtube.com/channel/UCFezKSxdNKJe77-hYiuXu3Q).
|
||||||
|
|
||||||
|
## Guide
|
||||||
|
|
||||||
|
### Step 1
|
||||||
|
|
||||||
|
After extracting the `.zip`, open `DiscordChatExporter.exe`
|
||||||
|
|
||||||
|
### Step 2
|
||||||
|
|
||||||
|
Please refer to the on-screen instructions to get your token, then paste your token in the upper text box and hit ENTER or click the arrow (→).
|
||||||
|
|
||||||
|
> **Warning**:
|
||||||
|
> **Never share your token!**
|
||||||
|
> A token gives full access to an account, treat it like a password.
|
||||||
|
|
||||||
|
<img src="https://i.imgur.com/SuLQ5tZ.png" height="400"/>
|
||||||
|
|
||||||
|
### Step 3
|
||||||
|
|
||||||
|
DCE will display your Direct Messages and a sidebar with your server list. Select the channel you would like to export, then click the  button to continue.
|
||||||
|
|
||||||
|
> **Note**:
|
||||||
|
> You can export multiple channels at once by holding `CTRL` or `SHIFT` while selecting.
|
||||||
|
> You can also double-click a channel to export it without clicking the  button.
|
||||||
|
|
||||||
|
<img src="https://i.imgur.com/JHMFRh2.png" height="400"/>
|
||||||
|
|
||||||
|
### Step 4
|
||||||
|
|
||||||
|
In this screen you can customize the following:
|
||||||
|
|
||||||
|
- **Output path** - The folder where the exported chat(s) will be saved.
|
||||||
|
|
||||||
|
- **Export format** - HTML (Dark), HTML (Light), TXT, CSV and JSON
|
||||||
|
|
||||||
|
- **Date range (after/before)** (Optional) - If set, only messages sent in the provided date range will be exported. Only one value (either after or before) is required if you want to use this option.
|
||||||
|
> **Note**:
|
||||||
|
> Please note that the time defaults to **12:00 AM** (midnight/00:00). This means that if you choose to export between Sep 17th and Sep 18th, messages from Sep 18th won't be exported.
|
||||||
|
|
||||||
|
- **Partition limit** (Optional) - Split output into partitions, each limited to this number of messages (e.g. 100) or file size (e.g. 10mb). For example, a channel with 36 messages set to be partitioned every 10 messages will output 4 files.
|
||||||
|
|
||||||
|
- **Message Filter** (Optional) - Special notation for filtering the messages that get included in the export. See [Message filters](Message-filters.md) for more info.
|
||||||
|
|
||||||
|
- **Format markdown** (Optional) - Disable markdown processing when exporting. You can use this to produce JSON or plain text exports without unwrapping mentions, custom emoji, and certain other special tokens.
|
||||||
|
|
||||||
|
- **Download assets** (Optional) - If this option is set, the export will include additional files such as user avatars, attached files, images, etc. Only files that are referenced by the export are downloaded, which means that, for example, user avatars will not be downloaded when using the plain text (TXT) export format. A folder containing the assets will be created along with the exported chat. They must be kept together.
|
||||||
|
|
||||||
|
- **Reuse assets** (Optional) - If this option is set, the export will reuse already downloaded assets to skip redundant requests. This option is only available when **Download assets** is enabled.
|
||||||
|
|
||||||
|
- **Assets directory path** (Optional) - If this option is set, the export will use the specified directory to store assets from all exported channels in the same place.
|
||||||
|
|
||||||
|
> **Note**:
|
||||||
|
> You need to scroll down to see all available options.
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
|
||||||
|
- **Auto-update**
|
||||||
|
Perform automatic updates on every launch.
|
||||||
|
Default: Enabled
|
||||||
|
|
||||||
|
> **Note**:
|
||||||
|
> Keep this option enabled to receive the latest features and bug fixes!
|
||||||
|
|
||||||
|
- **Dark mode**
|
||||||
|
Use darker colors in the UI (User Interface).
|
||||||
|
Default: Disabled
|
||||||
|
|
||||||
|
- **Persist token**
|
||||||
|
Persist last used token between sessions.
|
||||||
|
Default: Enabled
|
||||||
|
|
||||||
|
- **Show threads**
|
||||||
|
Controls whether threads are shown in the channel list.
|
||||||
|
Default: none
|
||||||
|
|
||||||
|
- **Locale**
|
||||||
|
Customize how dates are formatted in the exported files.
|
||||||
|
|
||||||
|
- **Date format**
|
||||||
|
Customize how dates are formatted in the exported files in the settings menu ().
|
||||||
|
|
||||||
|
- **Parallel limit**
|
||||||
|
The number of channels that will be exported at the same time.
|
||||||
|
Default: 1
|
||||||
|
|
||||||
|
- **Normalize to UTC**
|
||||||
|
Convert all dates to UTC before exporting.
|
||||||
|
|
||||||
|
> **Note**:
|
||||||
|
> Try to keep this number low so that your account doesn't get flagged.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
name: 🐞 Bug report
|
name: 🐛 Bug report
|
||||||
description: Report broken functionality.
|
description: Report broken functionality.
|
||||||
labels: [bug]
|
labels: [bug]
|
||||||
|
|
||||||
@@ -6,26 +6,25 @@ body:
|
|||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
value: |
|
value: |
|
||||||
🧐 **Guidelines:**
|
- Avoid generic or vague titles such as "Something's not working" or "A couple of problems" — be as descriptive as possible.
|
||||||
|
- Keep your issue focused on one single problem. If you have multiple bug reports, please create a separate issue for each of them.
|
||||||
|
- Issues should represent **complete and actionable** work items. If you are unsure about something or have a question, please start a [discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new) instead.
|
||||||
|
- Remember that **DiscordChatExporter** is an open-source project funded by the community. If you find it useful, **please consider [donating](https://tyrrrz.me/donate) to support its development**.
|
||||||
|
|
||||||
- Search through [existing issues](https://github.com/Tyrrrz/DiscordChatExporter/issues?q=is%3Aissue) first to ensure that this bug has not been reported before.
|
___
|
||||||
- Write a descriptive title for your issue. Avoid generic or vague titles such as "Something's not working" or "A couple of problems".
|
|
||||||
- Keep your issue focused on one single problem. If you have multiple bug reports, please create separate issues for each of them.
|
|
||||||
- Provide as much context as possible in the details section. Include screenshots, screen recordings, links, references, or anything else you may consider relevant.
|
|
||||||
- If you want to ask a question instead of reporting a bug, please use [discussions](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new) instead.
|
|
||||||
|
|
||||||
- type: input
|
- type: input
|
||||||
attributes:
|
attributes:
|
||||||
label: Version
|
label: Version
|
||||||
description: Which version of DiscordChatExporter does this bug affect?
|
description: Which version of the application does this bug affect? Make sure you're not using an outdated version.
|
||||||
placeholder: ver X.Y.Z
|
placeholder: v1.0.0
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
attributes:
|
attributes:
|
||||||
label: Flavor
|
label: Flavor
|
||||||
description: Does this bug affect the GUI version, the CLI version, or both?
|
description: Which flavor(s) of the application does this bug affect?
|
||||||
multiple: true
|
multiple: true
|
||||||
options:
|
options:
|
||||||
- GUI (Graphical User Interface)
|
- GUI (Graphical User Interface)
|
||||||
@@ -33,10 +32,18 @@ body:
|
|||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Platform
|
||||||
|
description: Which platform do you experience this bug on?
|
||||||
|
placeholder: Docker / Windows 11
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
attributes:
|
attributes:
|
||||||
label: Export format
|
label: Export format
|
||||||
description: Does this bug affect specific export format(s)? If not applicable, leave this field blank.
|
description: Which export format(s) do you experience this bug with, if applicable?
|
||||||
multiple: true
|
multiple: true
|
||||||
options:
|
options:
|
||||||
- HTML
|
- HTML
|
||||||
@@ -44,21 +51,57 @@ body:
|
|||||||
- JSON
|
- JSON
|
||||||
- CSV
|
- CSV
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Details
|
|
||||||
description: Clear and thorough explanation of the bug.
|
|
||||||
placeholder: I was doing X expecting Y to happen, but Z happened instead.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Steps to reproduce
|
label: Steps to reproduce
|
||||||
description: Minimum steps required to reproduce the bug.
|
description: >
|
||||||
|
Minimum steps required to reproduce the bug, including prerequisites, export settings, or other relevant items.
|
||||||
|
The information provided in this field must be readily actionable, meaning that anyone should be able to reproduce the bug by following these steps.
|
||||||
|
If the bug depends on external factors (such as a specific server, channel, or message), then this field must include the server invite and the corresponding link.
|
||||||
placeholder: |
|
placeholder: |
|
||||||
|
Server invite: https://discord.gg/...
|
||||||
|
Channel or message link: https://discord.com/channels/.../...
|
||||||
|
|
||||||
|
Export settings:
|
||||||
|
- ...
|
||||||
|
|
||||||
|
Application settings:
|
||||||
|
- ...
|
||||||
|
|
||||||
|
Steps:
|
||||||
- Step 1
|
- Step 1
|
||||||
- Step 2
|
- Step 2
|
||||||
- Step 3
|
- Step 3
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Details
|
||||||
|
description: Clear and thorough explanation of the bug, including any additional information you may find relevant.
|
||||||
|
placeholder: |
|
||||||
|
- Expected behavior: ...
|
||||||
|
- Actual behavior: ...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Checklist
|
||||||
|
description: Quick list of checks to ensure that everything is in order.
|
||||||
|
options:
|
||||||
|
- label: I have looked through existing issues to make sure that this bug has not been reported before
|
||||||
|
required: true
|
||||||
|
- label: I have provided a descriptive title for this issue
|
||||||
|
required: true
|
||||||
|
- label: I have made sure that this bug is reproducible on the latest version of the application
|
||||||
|
required: true
|
||||||
|
- label: I have provided all the information needed to reproduce this bug as efficiently as possible
|
||||||
|
required: true
|
||||||
|
- label: I have sponsored this project
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
If you are struggling to provide actionable reproduction steps, or if something else is preventing you from creating a complete bug report, please start a [discussion](https://github.com/Tyrrrz/DiscordChatExporter/discussions/new) instead.
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ contact_links:
|
|||||||
- name: ⚠ Feature request
|
- name: ⚠ Feature request
|
||||||
url: https://github.com/Tyrrrz/.github/blob/master/docs/project-status.md
|
url: https://github.com/Tyrrrz/.github/blob/master/docs/project-status.md
|
||||||
about: Sorry, but this project is in maintenance mode and no longer accepts new feature requests.
|
about: Sorry, but this project is in maintenance mode and no longer accepts new feature requests.
|
||||||
- name: 💬 Discord server
|
|
||||||
url: https://discord.gg/2SUWKFnHSm
|
|
||||||
about: Chat with the project community.
|
|
||||||
- name: 📖 Documentation
|
- name: 📖 Documentation
|
||||||
url: https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs
|
url: https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs
|
||||||
about: Find usage guides and frequently asked questions.
|
about: Find usage guides and frequently asked questions.
|
||||||
- name: 🗨 Discussions
|
- name: 🗨 Discussions
|
||||||
url: https://github.com/Tyrrrz/DiscordChatExporter/discussions/new
|
url: https://github.com/Tyrrrz/DiscordChatExporter/discussions/new
|
||||||
about: Ask and answer questions.
|
about: Ask and answer questions.
|
||||||
|
- name: 💬 Discord server
|
||||||
|
url: https://discord.gg/2SUWKFnHSm
|
||||||
|
about: Chat with the project community.
|
||||||
|
|||||||
@@ -1,55 +1,77 @@
|
|||||||
name: docker
|
name: docker
|
||||||
|
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
# Outputs from this job aren't really used, but it's here to verify that the Dockerfile builds correctly
|
||||||
|
pack:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
|
|
||||||
- name: Build container
|
- name: Install Docker Buildx
|
||||||
run: docker build -f DiscordChatExporter.Cli.dockerfile .
|
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
||||||
|
|
||||||
|
- name: Build image
|
||||||
|
run: >
|
||||||
|
docker buildx build .
|
||||||
|
--file DiscordChatExporter.Cli.dockerfile
|
||||||
|
--platform linux/amd64,linux/arm64
|
||||||
|
--build-arg VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }}
|
||||||
|
--output type=tar,dest=DiscordChatExporter.Cli.Docker.tar
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
|
||||||
|
with:
|
||||||
|
name: DiscordChatExporter.Cli.Docker
|
||||||
|
path: DiscordChatExporter.Cli.Docker.tar
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
# Deploy to DockerHub only on tag push or master branch push
|
||||||
|
if: ${{ github.ref_type == 'tag' || github.ref_type == 'branch' && github.ref_name == 'master' }}
|
||||||
|
|
||||||
deploy-latest:
|
|
||||||
if: ${{ github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
|
|
||||||
|
- name: Install Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
run: docker login -u tyrrrz -p ${{ secrets.DOCKER_TOKEN }}
|
run: >
|
||||||
|
echo ${{ secrets.DOCKER_TOKEN }} |
|
||||||
|
docker login --username tyrrrz --password-stdin
|
||||||
|
|
||||||
- name: Build container
|
- name: Build & push image
|
||||||
run: docker build -f DiscordChatExporter.Cli.dockerfile -t tyrrrz/discordchatexporter:latest .
|
run: >
|
||||||
|
docker buildx build .
|
||||||
- name: Push container
|
--file DiscordChatExporter.Cli.dockerfile
|
||||||
run: docker push tyrrrz/discordchatexporter:latest
|
--platform linux/amd64,linux/arm64
|
||||||
|
--build-arg VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }}
|
||||||
deploy-stable:
|
--push
|
||||||
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
|
--tag tyrrrz/discordchatexporter:latest
|
||||||
runs-on: ubuntu-latest
|
${{ github.ref_type == 'tag' && '--tag tyrrrz/discordchatexporter:$GITHUB_REF_NAME' || '' }}
|
||||||
|
${{ github.ref_type == 'tag' && '--tag tyrrrz/discordchatexporter:stable' || '' }}
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Get release version
|
|
||||||
id: get_version
|
|
||||||
uses: dawidd6/action-get-tag@v1
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
run: docker login -u tyrrrz -p ${{ secrets.DOCKER_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build container
|
|
||||||
run: docker build -f DiscordChatExporter.Cli.dockerfile -t tyrrrz/discordchatexporter:stable -t tyrrrz/discordchatexporter:${{ steps.get_version.outputs.tag }} .
|
|
||||||
|
|
||||||
- name: Push container (stable)
|
|
||||||
run: docker push tyrrrz/discordchatexporter:stable
|
|
||||||
|
|
||||||
- name: Push container (${{ steps.get_version.outputs.tag }})
|
|
||||||
run: docker push tyrrrz/discordchatexporter:${{ steps.get_version.outputs.tag }}
|
|
||||||
|
|||||||
+182
-77
@@ -1,129 +1,234 @@
|
|||||||
name: main
|
name: main
|
||||||
|
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||||
|
DOTNET_NOLOGO: true
|
||||||
|
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
format:
|
||||||
runs-on: windows-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
env:
|
permissions:
|
||||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
contents: read
|
||||||
DOTNET_NOLOGO: true
|
|
||||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
|
|
||||||
- name: Install .NET
|
- name: Install .NET
|
||||||
uses: actions/setup-dotnet@v2
|
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: 7.0.x
|
dotnet-version: 8.0.x
|
||||||
|
|
||||||
|
- name: Verify formatting
|
||||||
|
run: >
|
||||||
|
dotnet build
|
||||||
|
-t:CSharpierFormat
|
||||||
|
--configuration Release
|
||||||
|
|
||||||
|
test:
|
||||||
|
# Tests need access to secrets, so we can't run them against PRs because of limited trust
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
|
|
||||||
|
- name: Install .NET
|
||||||
|
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
|
||||||
|
with:
|
||||||
|
dotnet-version: 8.0.x
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
# Tests need access to secrets, so we can't run them against PRs because of limited trust
|
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
|
||||||
run: dotnet test --configuration Release --logger GitHubActions --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
|
|
||||||
env:
|
env:
|
||||||
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
||||||
|
run: >
|
||||||
|
dotnet test
|
||||||
|
-p:CSharpier_Bypass=true
|
||||||
|
--configuration Release
|
||||||
|
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
|
||||||
|
--collect:"XPlat Code Coverage"
|
||||||
|
--
|
||||||
|
RunConfiguration.CollectSourceInformation=true
|
||||||
|
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
|
||||||
|
|
||||||
- name: Upload coverage
|
- name: Upload coverage
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@f30e4959ba63075080d4f7f90cacc18d9f3fafd7 # v4.0.0
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
package:
|
pack:
|
||||||
needs: test
|
strategy:
|
||||||
runs-on: windows-latest
|
matrix:
|
||||||
|
app:
|
||||||
|
- DiscordChatExporter.Cli
|
||||||
|
- DiscordChatExporter.Gui
|
||||||
|
rid:
|
||||||
|
- win-arm64
|
||||||
|
- win-x86
|
||||||
|
- win-x64
|
||||||
|
- linux-arm
|
||||||
|
- linux-arm64
|
||||||
|
- linux-musl-x64
|
||||||
|
- linux-x64
|
||||||
|
- osx-arm64
|
||||||
|
- osx-x64
|
||||||
|
include:
|
||||||
|
- app: DiscordChatExporter.Cli
|
||||||
|
asset: DiscordChatExporter.Cli
|
||||||
|
- app: DiscordChatExporter.Gui
|
||||||
|
# GUI assets aren't suffixed, unlike the CLI assets
|
||||||
|
asset: DiscordChatExporter
|
||||||
|
|
||||||
env:
|
# Need to run on Windows because of DotnetRuntimeBootstrapper's dependency on Ressy
|
||||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
runs-on: windows-latest
|
||||||
DOTNET_NOLOGO: true
|
timeout-minutes: 10
|
||||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
|
||||||
|
permissions:
|
||||||
|
actions: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
|
|
||||||
- name: Install .NET
|
- name: Install .NET
|
||||||
uses: actions/setup-dotnet@v2
|
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: 7.0.x
|
dotnet-version: 8.0.x
|
||||||
|
|
||||||
- name: Publish (CLI)
|
- name: Publish app
|
||||||
run: dotnet publish DiscordChatExporter.Cli/ -o DiscordChatExporter.Cli/bin/Publish/ --configuration Release
|
run: >
|
||||||
|
dotnet publish ${{ matrix.app }}
|
||||||
|
-p:Version=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }}
|
||||||
|
-p:CSharpier_Bypass=true
|
||||||
|
--output ${{ matrix.app }}/bin/publish/
|
||||||
|
--configuration Release
|
||||||
|
--runtime ${{ matrix.rid }}
|
||||||
|
--no-self-contained
|
||||||
|
|
||||||
- name: Publish (GUI)
|
- name: Upload artifacts
|
||||||
run: dotnet publish DiscordChatExporter.Gui/ -o DiscordChatExporter.Gui/bin/Publish/ --configuration Release
|
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
|
||||||
|
|
||||||
- name: Upload artifacts (CLI)
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
with:
|
||||||
name: DiscordChatExporter.Cli
|
name: ${{ matrix.asset }}.${{ matrix.rid }}
|
||||||
path: DiscordChatExporter.Cli/bin/Publish/
|
path: ${{ matrix.app }}/bin/publish/
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload artifacts (GUI)
|
release:
|
||||||
uses: actions/upload-artifact@v3
|
if: ${{ github.ref_type == 'tag' }}
|
||||||
with:
|
|
||||||
name: DiscordChatExporter
|
needs:
|
||||||
path: DiscordChatExporter.Gui/bin/Publish/
|
- format
|
||||||
|
- test
|
||||||
|
- pack
|
||||||
|
|
||||||
deploy:
|
|
||||||
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
|
|
||||||
needs: package
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download artifacts (CLI)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: DiscordChatExporter.Cli
|
|
||||||
path: DiscordChatExporter.Cli
|
|
||||||
|
|
||||||
- name: Download artifacts (GUI)
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: DiscordChatExporter
|
|
||||||
path: DiscordChatExporter.Gui
|
|
||||||
|
|
||||||
- name: Create package (CLI)
|
|
||||||
run: Compress-Archive -Path DiscordChatExporter.Cli/* -DestinationPath DiscordChatExporter.Cli.zip -Force
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
- name: Create package (GUI)
|
|
||||||
run: Compress-Archive -Path DiscordChatExporter.Gui/* -DestinationPath DiscordChatExporter.zip -Force
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: >
|
||||||
|
gh release create ${{ github.ref_name }}
|
||||||
|
--repo ${{ github.event.repository.full_name }}
|
||||||
|
--title ${{ github.ref_name }}
|
||||||
|
--generate-notes
|
||||||
|
--verify-tag
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: release
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
app:
|
||||||
|
- DiscordChatExporter.Cli
|
||||||
|
- DiscordChatExporter.Gui
|
||||||
|
rid:
|
||||||
|
- win-arm64
|
||||||
|
- win-x86
|
||||||
|
- win-x64
|
||||||
|
- linux-arm
|
||||||
|
- linux-arm64
|
||||||
|
- linux-musl-x64
|
||||||
|
- linux-x64
|
||||||
|
- osx-arm64
|
||||||
|
- osx-x64
|
||||||
|
include:
|
||||||
|
- app: DiscordChatExporter.Cli
|
||||||
|
asset: DiscordChatExporter.Cli
|
||||||
|
- app: DiscordChatExporter.Gui
|
||||||
|
# GUI assets aren't suffixed, unlike the CLI assets
|
||||||
|
asset: DiscordChatExporter
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
|
||||||
with:
|
with:
|
||||||
files: |
|
name: ${{ matrix.asset }}.${{ matrix.rid }}
|
||||||
DiscordChatExporter.Cli.zip
|
path: ${{ matrix.app }}/
|
||||||
DiscordChatExporter.zip
|
|
||||||
body: |
|
- name: Create package
|
||||||
[Changelog](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/Changelog.md)
|
# Change into the artifacts directory to avoid including the directory itself in the zip archive
|
||||||
|
working-directory: ${{ matrix.app }}/
|
||||||
|
run: zip -r ../${{ matrix.asset }}.${{ matrix.rid }}.zip .
|
||||||
|
|
||||||
|
- name: Upload release asset
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: >
|
||||||
|
gh release upload ${{ github.ref_name }}
|
||||||
|
${{ matrix.asset }}.${{ matrix.rid }}.zip
|
||||||
|
--repo ${{ github.event.repository.full_name }}
|
||||||
|
|
||||||
notify:
|
notify:
|
||||||
needs: deploy
|
needs: deploy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Get release version
|
|
||||||
id: get_version
|
|
||||||
uses: dawidd6/action-get-tag@v1
|
|
||||||
|
|
||||||
- name: Notify Discord
|
- name: Notify Discord
|
||||||
uses: satak/webrequest-action@v1.2.4
|
uses: tyrrrz/action-http-request@64c70c67f5ebc54d4c7ea09cbe3553322778afd5 # 1.1.2
|
||||||
with:
|
with:
|
||||||
url: ${{ secrets.DISCORD_WEBHOOK }}
|
url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
method: POST
|
method: POST
|
||||||
headers: |
|
headers: |
|
||||||
|
Content-Type: application/json; charset=UTF-8
|
||||||
|
body: |
|
||||||
{
|
{
|
||||||
"ContentType": "application/json; charset=UTF-8"
|
"avatar_url": "https://raw.githubusercontent.com/${{ github.event.repository.full_name }}/${{ github.ref_name }}/favicon.png",
|
||||||
|
"content": "[**${{ github.event.repository.name }}**](<${{ github.event.repository.html_url }}>) v${{ github.ref_name }} has been released!"
|
||||||
}
|
}
|
||||||
payload: |
|
retry-count: 5
|
||||||
{
|
|
||||||
"content": "**DiscordChatExporter** new version released!\nVersion: `${{ steps.get_version.outputs.tag }}`\nChangelog: <https://github.com/Tyrrrz/DiscordChatExporter/blob/${{ steps.get_version.outputs.tag }}/Changelog.md>"
|
|
||||||
}
|
|
||||||
|
|||||||
+6
-17
@@ -1,23 +1,12 @@
|
|||||||
# User-specific files
|
# User-specific files
|
||||||
|
.vs/
|
||||||
|
.idea/
|
||||||
*.suo
|
*.suo
|
||||||
*.user
|
*.user
|
||||||
*.userosscache
|
|
||||||
*.sln.docstates
|
|
||||||
.idea/
|
|
||||||
.vs/
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
# Build results
|
# Build results
|
||||||
[Dd]ebug/
|
bin/
|
||||||
[Dd]ebugPublic/
|
obj/
|
||||||
[Rr]elease/
|
|
||||||
[Rr]eleases/
|
|
||||||
[Xx]64/
|
|
||||||
[Xx]86/
|
|
||||||
[Bb]uild/
|
|
||||||
bld/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
|
|
||||||
# Coverage
|
# Test results
|
||||||
*.opencover.xml
|
TestResults/
|
||||||
-515
@@ -1,515 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
## v2.38 (16-Feb-2023)
|
|
||||||
|
|
||||||
- General changes:
|
|
||||||
- Added support for different formatting options when rendering timestamps (i.e. the `f` in `<t:1234567890:f>`). As an exception, relative timestamps are formatted as regular timestamps since that makes more sense in a static export. Currently, all formatting options are rendered based on the `English (US)` locale, with the intent to make that more configurable in the future.
|
|
||||||
- Added an option to disable markdown processing when exporting. You can use this to produce JSON or plain text exports without unwrapping mentions, custom emoji, and certain other special tokens.
|
|
||||||
- Moved the "reuse assets" option from the settings dialog to the export dialog.
|
|
||||||
- Changed the default date format from `dd-MMM-yy hh:mm tt` to `MM/dd/yyyy h:mm tt` to match the date format used by Discord for message timestamps when the `English (US)` language is selected. This should make the default date format more consistent with other non-configurable date formats used by DiscordChatExporter. In the future, this setting will most likely be removed entirely in favor of a more flexible approach.
|
|
||||||
- Updated the usage guide with additional steps required to retrieve the user token.
|
|
||||||
- Fixed an issue where certain user mentions were incorrectly rendered as `@Unknown`.
|
|
||||||
- Fixed an issue where some embed images were rendered using their actual URLs instead of Discord proxy URLs.
|
|
||||||
- GUI changes:
|
|
||||||
- Added a text box for specifying the output path when exporting channels. It can be used to set an output path that uses template tokens, which previously required hacky workarounds. This text box can be left empty, in which case clicking on the "Export" button will open the file or folder picker dialog, matching the current behavior.
|
|
||||||
- Added a notification when the application is updated to a new version, containing the changelog link.
|
|
||||||
- Replaced the lock icon in the token text box with a key icon, to better reflect the purpose of the input.
|
|
||||||
- Minor cosmetic improvements.
|
|
||||||
- CLI changes:
|
|
||||||
- Changed the behavior of the `export` command when providing IDs of category channels. Now, instead of displaying an error, the command will export all channels contained within the corresponding categories.
|
|
||||||
- HTML format changes:
|
|
||||||
- Added proper support for more system notification messages.
|
|
||||||
- Added support for rendering server invites. Now, if the message contains an invite link, the export will show the server icon and include additional information, such as the name of the server and the target channel.
|
|
||||||
- Changed the preamble part of the export to show the channel icon when available, instead of the default Discord logo. This is only available for group DM channels.
|
|
||||||
- Fixed an issue where some miscellaneous characters were incorrectly treated as emoji, which resulted in them being rendered as broken images. (Thanks [@CanePlayz](https://github.com/CanePlayz))
|
|
||||||
- Fixed an issue where messages triggered by app interactions were not rendered as replies.
|
|
||||||
- Fixed an issue where server cross-posts were not rendered correctly.
|
|
||||||
- JSON format changes:
|
|
||||||
- Added an `iconUrl` field for the top-level `channel` object, which specifies the URL of the channel icon. This is only available for group DM channels.
|
|
||||||
- Added a `code` field for reactions, which specifies the code of the associated emoji. For standard Unicode emoji, this is equal to the emoji alias (e.g. `slightly_smiling_face`). For custom Discord emoji, this is equal to the emoji name (same as the already existing `name` field).
|
|
||||||
- Added an `interaction` field for messages, which contains information about the app interaction that triggered that response, if applicable.
|
|
||||||
|
|
||||||
## v2.37.2 (27-Jan-2023)
|
|
||||||
|
|
||||||
- Updated the links inside the application to point to the new documentation site. (Thanks [@CanePlayz](https://github.com/CanePlayz))
|
|
||||||
- [CLI] Fixed an issue that there was no visual indication that an export task has failed before the whole process has completed.
|
|
||||||
- Fixed an issue where the application sometimes crashed when it couldn't establish an HTTP connection to the target server.
|
|
||||||
|
|
||||||
## v2.37.1 (10-Jan-2023)
|
|
||||||
|
|
||||||
- [HTML] Fixed an issue where the export failed because it failed to resolve standard emoji image assets. Switched to a different CDN provider to mitigate this. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- [GUI] Fixed an application crash that happened when the user attempted to close the same dialog multiple times in a very short time.
|
|
||||||
|
|
||||||
## v2.37 (08-Jan-2023)
|
|
||||||
|
|
||||||
- Switched from .NET 6.0 to .NET 7.0. If running on Windows, the application should update all required prerequisites automatically. Alternatively, you can download the latest version of the runtime for your system [here](https://dotnet.microsoft.com/download/dotnet/7.0).
|
|
||||||
- Updated rate limit handling to adjust automatically based on the response headers. This may result in exports taking longer than before on bot accounts, but it makes it less likely for Discord to throttle you. Exports with user accounts shouldn't be affected too much by this change.
|
|
||||||
- Optimized snowflake parsing by removing unnecessary checks. (Thanks [@Kuba_Z2](https://github.com/KubaZ2))
|
|
||||||
- [Docker] Optimized the Docker image size by using the Alpine base image and publishing a self-contained distribution. (Thanks [@Velithris](https://github.com/Zireael-N))
|
|
||||||
- Fixed an issue where exporting a channel whose name ends with a dot would fail on Windows with default output path. The dots are now trimmed in file and directory names to match the behavior of Windows Explorer.
|
|
||||||
|
|
||||||
## v2.36.4 (29-Oct-2022)
|
|
||||||
|
|
||||||
- Changed all mentions of "media" in the context of "download media" or "reuse media" to "assets". CLI options will retain their existing names for backwards compatibility.
|
|
||||||
- [HTML] Fixed an issue which prevented emoji used inside message content from being downloaded when "download assets" option is enabled. (Thanks [@Roberto Blázquez](https://github.com/xBaank))
|
|
||||||
|
|
||||||
## v2.36.3 (21-Oct-2022)
|
|
||||||
|
|
||||||
- [GUI] Fixed an issue where opening a dialog did not prevent user interactions with background UI elements using keyboard. This sometimes caused the application to crash in weird ways.
|
|
||||||
- [Docker] Fixed an issue where DiscordChatExporter was running as root inside the container, making the exported files inaccessible to the host. (Thanks [@Benjamin Just](https://github.com/BamButz))
|
|
||||||
|
|
||||||
## v2.36.2 (08-Oct-2022)
|
|
||||||
|
|
||||||
- Removed the message content intent check because the heuristics turned out to be not reliable enough.
|
|
||||||
- Fixed an issue where the runtime manifest included the wrong target runtime version. This resulted in the application failing to launch for some users when upgrading from earlier versions.
|
|
||||||
|
|
||||||
## v2.36.1 (24-Sep-2022)
|
|
||||||
|
|
||||||
- Added a check which will trigger an error if the provided bot account does not have the message content intent enabled. Note, however, that this check is based on heuristics which may result in false negatives.
|
|
||||||
- Fixed an issue where certain transient HTTP errors were not retried.
|
|
||||||
- Fixed an issue which caused the export process to fail with the `IndexOutOfRangeException` exception on certain automated messages.
|
|
||||||
- Fixed an issue which caused the export process to fail on unrecognized embed types.
|
|
||||||
|
|
||||||
## v2.36 (16-Sep-2022)
|
|
||||||
|
|
||||||
- [HTML] Added support for rendering GIFV embeds. They will now render as videos that automatically play when you hover your mouse over them. (Thanks [@gan-of-culture](https://github.com/gan-of-culture))
|
|
||||||
- [HTML] Added support for rendering system notification messages, such as when a user joins a server or when a messages gets pinned. Previously, such messages were rendered as regular text messages, but now they look similar to how they're presented in the Discord client. (Thanks [@gan-of-culture](https://github.com/gan-of-culture))
|
|
||||||
- [CLI] Improved the wording of the error message that's shown when exporting multiple channels and the provided output path is ambiguous. It now mentions that you can resolve the ambiguity by adding a slash at the end of the path.
|
|
||||||
|
|
||||||
## v2.35.2 (08-Sep-2022)
|
|
||||||
|
|
||||||
- Updated usage guide to mention the need to enable "Message Content Intent" to use a bot as a medium for exporting messages.
|
|
||||||
- [CLI] Fixed an issue where passing an existing directory as the output path failed when exporting multiple channels (for example, when running `exportdm`). An ambiguous output path will now always be treated as a directory path if that directory already exists. If it doesn't exist, it will be treated as a file path, matching the previous behavior.
|
|
||||||
|
|
||||||
## v2.35.1 (26-Aug-2022)
|
|
||||||
|
|
||||||
- Added `~` character as an alias for `-` when negating a message filter. This should make it easier to use negated filters from CLI where the dash character already has other meanings.
|
|
||||||
- Extended retry logic to encompass all server-side errors from Discord API, instead of only `500 Internal Server Error`.
|
|
||||||
- [CLI] Attempt to export multiple channels will now fail if provided with an output path that is neither a directory, nor a file name template. Previously, this resulted in all channels being exported to the same file, overwriting each other.
|
|
||||||
- Fixed an issue where a text message filter didn't work if it started with a character that's also the first character in one of the named filters (e.g. `from` or `mentions`).
|
|
||||||
- Fixed an issue where a text message filter didn't work correctly if it was enclosed in parentheses.
|
|
||||||
- Fixed an issue where categories were displayed alongside regular channels in the channel list, both in GUI and in CLI (when using the `guild` command).
|
|
||||||
- [CLI] Fixed an issue where an output path starting with a tilde on Linux was not expanded properly into a full path. (Thanks [@TSRBerry](https://github.com/TSRBerry))
|
|
||||||
|
|
||||||
## v2.35 (02-Jul-2022)
|
|
||||||
|
|
||||||
- Added support for exporting text chat in voice channels. These channels are now also displayed when browsing in the GUI and in the CLI when executing the `channels` command.
|
|
||||||
- [GUI] Direct message channels are now sorted by the timestamp of their last message, similarly to how they appear in the Discord client.
|
|
||||||
- [GUI] Removed artificial grouping of direct message channels into "Private" and "Group".
|
|
||||||
- [CLI] Added runtime bootstrapper capabilities to the CLI flavor of DiscordChatExporter on Windows. Now, if you attempt to run the application without the required prerequisites installed, you will be provided with an option to install them automatically.
|
|
||||||
- [CLI] Fixed outdated information in the usage guide. (Thanks [@Clint Herron](https://github.com/HanClinto))
|
|
||||||
- [CLI] Added whitespace padding to the output of `guilds`, `channels`, and `dm` to make the tables look more uniform.
|
|
||||||
- [HTML] Added hyperlinks to message timestamps, which allows you to quickly copy a link to a specific message in the export. (Thanks [@Philipp C. Heckel](https://github.com/binwiederhier))
|
|
||||||
- [HTML] Added minification. Chat exports in HTML format are now 30-35% smaller than before.
|
|
||||||
- [HTML] Added support for rendering embeds of Twitter posts that contain multiple images. Previously, this resulted in multiple separate embeds instead of one.
|
|
||||||
- [HTML] Added support for rendering embeds of YouTube Shorts videos.
|
|
||||||
- [HTML] Text content is now hidden if the message only contains a link to an image and nothing else. The link itself is resolved as an image embed.
|
|
||||||
- [HTML] Fixed an issue where some emoji that included a zero-width-joiner rune were not rendered correctly due to a wrong Twemoji URL being generated. (Thanks [@Ethan](https://github.com/ethanndickson))
|
|
||||||
- [HTML] Fixed an issue where replies to a message that contained a quote (i.e. `>`) were not rendered correctly.
|
|
||||||
- [HTML] Fixed an issue where code blocks with language highlighting did not have the correct background color.
|
|
||||||
- Added file name template token that resolves to the current date (`%d`). (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- Updated the usage guide to replace the instructions for retrieving the user token with those that appear to work for more people.
|
|
||||||
- Updated the usage guide to feature the TOS warning more prominently.
|
|
||||||
- [Docker] Changed internal working directory from `/app/out` to `/out`. This was an unintended breaking change. Please update your volume binding configuration from `-v /path/on/machine:/app/out` to `-v /path/on/machine:/out`.
|
|
||||||
|
|
||||||
## v2.34.1 (01-Jun-2022)
|
|
||||||
|
|
||||||
- Improved retry policy to handle more transient errors. This should result in fewer errors exporting a channel due to timeout.
|
|
||||||
- Added `has:pin` message filter. You can use it to limit exported messages to those that have been pinned. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- Fixed an issue which caused the export to fail when processing stickers that have no name.
|
|
||||||
|
|
||||||
## v2.34 (10-Apr-2022)
|
|
||||||
|
|
||||||
- [HTML] Reworked layout to be more consistent with Discord.
|
|
||||||
- [HTML] Changed user profile picture dimensions from `128x128` to `512x512`. (Thanks [@Chris Helder](https://github.com/TheDude53))
|
|
||||||
- [HTML] Improved image scaling for Chromium-based browsers. This should result in higher quality images across the entire export.
|
|
||||||
- [HTML] Hovering over messages will now show short timestamps on the left, indicating the time that the individual messages of the group were sent.
|
|
||||||
- [HTML] Using "download media" option will now also download scripts, styles, fonts, and other similar resources used by the export.
|
|
||||||
- [HTML] Image attachments will now use the provided description as alt text.
|
|
||||||
- [HTML] Fixed a few layout inconsistencies related to embeds.
|
|
||||||
- [GUI] Added a few clickable links to the usage guide to make the process of locating tokens easier.
|
|
||||||
|
|
||||||
## v2.33.2 (07-Mar-2022)
|
|
||||||
|
|
||||||
- Actually fixed it this time.
|
|
||||||
|
|
||||||
## v2.33.1 (07-Mar-2022)
|
|
||||||
|
|
||||||
- Fixed an issue where the application silently failed to run if the system didn't have .NET Runtime 6.0.2 installed. If you continue seeing this issue, please uninstall all existing .NET runtimes from your computer and then try running the application again.
|
|
||||||
|
|
||||||
## v2.33 (06-Mar-2022)
|
|
||||||
|
|
||||||
- Added messages informing about war in Ukraine and available ways to help.
|
|
||||||
- Added support for rendering stickers in HTML and JSON. Lottie-based stickers currently cannot be displayed in HTML exports (see [#803](https://github.com/Tyrrrz/DiscordChatExporter/issues/803)).
|
|
||||||
- Added a new `reaction:` message filter which can be used to check if someone reacted to a message with a specific emoji. You can either pass the emoji name (e.g. `reaction:LUL`) or its ID (e.g. `reaction:41771983429993937`).
|
|
||||||
- [GUI] Added auto-detection for dark mode. If your system is configured to prefer dark mode in applications, DiscordChatExporter will use it by default instead of light mode.
|
|
||||||
- Fixed an issue which caused the export process to crash when downloading media files with extremely long file extensions. (Thanks [@Tomlacko](https://github.com/Tomlacko))
|
|
||||||
- Fixed an issue which caused the export process to crash on invalid mentions.
|
|
||||||
- [GUI] Fixed an issue where the time pickers used to specify export ranges always displayed time in 12-hour format, instead of respecting the system locale.
|
|
||||||
|
|
||||||
## v2.32 (27-Jan-2022)
|
|
||||||
|
|
||||||
- Token kind (user or bot) is now detected automatically. Removed the button to switch token kind in GUI. Option `-b|--bot` in CLI is now deprecated and does nothing.
|
|
||||||
- Updated user token extraction guide to reflect the fact that devtools are no longer accessible in the desktop version of Discord client. The recommended workaround is to open Discord in browser. (Thanks [@Dhananjay-JSR](https://github.com/Dhananjay-JSR))
|
|
||||||
- Fixed an issue which caused an error when parsing invalid date timestamps. Such timestamps are now rendered as "Invalid date", similarly to how the Discord client does it.
|
|
||||||
- Fixed an issue which caused an error when parsing certain embed fields.
|
|
||||||
- Fixed an issue which caused an error when parsing a mention to a user that has no username.
|
|
||||||
- [GUI] Minor visual fixes.
|
|
||||||
|
|
||||||
## v2.31.1 (15-Dec-2021)
|
|
||||||
|
|
||||||
- Fixed an issue which caused an error when parsing certain custom emoji reactions.
|
|
||||||
- [GUI] Improved user interface.
|
|
||||||
|
|
||||||
## v2.31 (06-Dec-2021)
|
|
||||||
|
|
||||||
- Changed target runtime of the application (both GUI and CLI) from .NET 3.1 to .NET 6. Those using the GUI version will not need to take any action as the application should install the necessary prerequisites automatically. Those using the CLI version will need to download and install .NET 6 runtime manually [from here](https://dotnet.microsoft.com/download/dotnet/6.0) (look for ".NET Runtime 6.0.x" section on the right and choose the distribution appropriate for your system).
|
|
||||||
- [HTML] Updated layout design to match Discord more closely. (Thanks [@Artem](https://github.com/Scarg))
|
|
||||||
- [HTML] Fixed an issue where markdown inside channel topic was not rendered correctly. (Thanks [@Emily](https://github.com/emillly-b))
|
|
||||||
- [HTML] Fixed an issue where the layout was broken for messages containing text in right-to-left languages. (Thanks [@Emily](https://github.com/emillly-b))
|
|
||||||
- Fixed an issue where text filters weren't matching content inside of embeds.
|
|
||||||
- [GUI] Fixed a multitude of issues related to the bootstrapper.
|
|
||||||
|
|
||||||
## v2.30.1 (28-Aug-2021)
|
|
||||||
|
|
||||||
- [HTML] Changed user avatars to render using higher resolution images. (Thanks [@Chris Helder](https://github.com/TheDude53))
|
|
||||||
- Fixed an issue where `has:file` message filter was not recognized. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- Fixed an issue where a unix timestamp marker with an invalid offset crashed the export process.
|
|
||||||
|
|
||||||
## v2.30 (08-Aug-2021)
|
|
||||||
|
|
||||||
- [HTML] Added special casing for Spotify track embeds to render them directly using an embedded player.
|
|
||||||
- [HTML] Added special casing for plain image embeds to render them like image attachments.
|
|
||||||
- [HTML] Added tooltip text for unix timestamp markers which shows the full date represented by the timestamp, regardless of configured date format.
|
|
||||||
- [HTML] Updated the fallback text shown when the referenced message could not be loaded to make it more explicit.
|
|
||||||
- [HTML] Updated styling of quoted text in markdown to more closely resemble how it looks in Discord.
|
|
||||||
- [HTML] Fixed an issue where some file formats were not correctly recognized as image or video attachments, which affected how they were rendered.
|
|
||||||
- [HTML] Fixed an issue where formatting inside named links (e.g. `[**Bold link**](https://example.com)`) was not being parsed.
|
|
||||||
- [HTML] Fixed an issue where inline embed fields were missing horizontal spacing between columns.
|
|
||||||
- [HTML] Fixed other minor styling issues.
|
|
||||||
|
|
||||||
## v2.29 (19-Jul-2021)
|
|
||||||
|
|
||||||
- Added support for message filtering, which is accessible as an additional export parameter in the GUI and as the `--filter` option in the CLI. Message filters use a special syntax similar to Discord's search query syntax to allow specifying which messages should be included in the export. For example, you can limit the export to only include messages that contain image attachments (`has:image`) or messages from a certain user (`from:Tyrrrz`) or messages containing certain words (`hello world`), etc. You can also combine filters together (`hi mentions:Tyrrrz`, `from:Tyrrrz | from:96-LB`, `(mentions:Tyrrrz | from:Tyrrrz) has:image`) or negate them (`-has:link`). More thorough documentation coming soon. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- Added support for rendering mentions of voice channels, in addition to text channels.
|
|
||||||
- Added support for rendering unix timestamp markers. Currently, style markers are ignored and timestamps are always rendered with the format configured in settings (or provided via `--date-format` option).
|
|
||||||
- Updated in-app instructions for obtaining a user token. (Thanks [@Yudi](https://github.com/Yudi) and [@virtuallyvlad](https://github.com/virtuallyvlad))
|
|
||||||
- [HTML] Improved visual appearance of the reference symbol (Г-shaped line in replies) to make it more closely resemble Discord's styling.
|
|
||||||
- [HTML] Added more specific fallback text used when rendering referenced messages that contain no text content but have attachments or embeds.
|
|
||||||
- [HTML] Fixed an issue where a broken embed author icon occupied visual space, ruining the embed layout. (Thanks [@Cliff J.](https://github.com/CliffJameston))
|
|
||||||
- [GUI] Improved handling for fatal errors that may occur when attempting to export a channel. These errors are now displayed in a popup, allowing the user to try again instead of having the application crash completely.
|
|
||||||
- [CLI] Fixed an issue where an attempt to export a channel resulted in `NotSupportedException` when the default encoding was set to `UTF8`.
|
|
||||||
- [CLI] Fixed an issue where providing an incorrectly formatted partition limit via `-p|--partition` option resulted in a non-descriptive and unhelpful error.
|
|
||||||
- Improved "Requested resource does not exist" error message by including the ID of the requested resource.
|
|
||||||
|
|
||||||
## v2.28 (19-Jun-2021)
|
|
||||||
|
|
||||||
- [HTML] Added special casing for YouTube video embeds to render them directly using an embedded player. (Thanks [@quentinmay](https://github.com/quentinmay))
|
|
||||||
- [HTML] Added support for rendering standard emoji by code. Such emoji may sometimes be found in messages sent by bots or through webhooks. (Thanks [@CanePlayz](https://github.com/CanePlayz) and [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- [HTML] Changed tooltips on standard emoji to show emoji code instead of their raw string representations. (Thanks [@CanePlayz](https://github.com/CanePlayz) and [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- [HTML] Added tooltips on individual messages to show when those messages were sent.
|
|
||||||
- [HTML] Updated colors and minor styling elements to match Discord's new style direction after rebranding.
|
|
||||||
- [HTML] Updated Twemoji URLs to use SVG image variants for better rendering quality.
|
|
||||||
- [HTML] Changed user avatar URLs to include predetermined size query parameter for better rendering quality.
|
|
||||||
- Changed embed rendering logic to prefer Discord-proxied URLs for external content, in order to avoid unnecessary HTTP requests to third parties.
|
|
||||||
- Fixed an issue where exporting with media sometimes resulted in a crash due to lack of permissions to change file attributes. These errors are now ignored, which means that the creation, write, and access dates of downloaded files may sometimes not match the dates provided by Discord's CDN.
|
|
||||||
- [HTML] Fixed styling issues when rendering embed footers.
|
|
||||||
- [HTML] Fixed an issue where links didn't render properly inside referenced messages.
|
|
||||||
- [HTML] Fixed an issue where standalone emoji were incorrectly enlarged inside referenced messages.
|
|
||||||
- [HTML] Fixed an issue where clicking on a referenced message revealed spoilers inside of it.
|
|
||||||
- [GUI] Fixed an issue where the list of missing components, reported by the prerequisite check at application startup, included Windows updates that were not applicable to the user's system due to the fact that other superseding updates have already been installed. This issue only affected users running DiscordChatExporter on Windows 7.
|
|
||||||
- [GUI] Fixed a few other minor issues related to the prerequisite installation window.
|
|
||||||
|
|
||||||
## v2.27.1 (08-Jun-2021)
|
|
||||||
|
|
||||||
- [GUI] Application will now detect if the required .NET Runtime or any of its prerequisites are missing and prompt the user to download and install them automatically. **Experimental feature, please test it out and report any issues you may find!**
|
|
||||||
- [CLI] Fixed an issue where the application crashed when exporting a channel that had square brackets as part of its name or category name. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
|
|
||||||
## v2.27 (24-Apr-2021)
|
|
||||||
|
|
||||||
- Added partitioning by file size. You can now use values such as `10mb` to indicate a size-based cut off point, in addition to values like `10` to indicate a number of messages. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- [CLI] Improved formatting and progress reporting.
|
|
||||||
- [CLI] Changed `export` command so that it can accept multiple channel IDs passed to `-c|--channel` option. This makes it possible to export multiple channels at once while benefiting from parallelization.
|
|
||||||
- [JSON] Added `color` field to message author. This is a hex string that represents user's color, inherited from their roles. (Thanks [@rtm516](https://github.com/rtm516))
|
|
||||||
- [JSON] Added `categoryId` field to the root. This represents the ID of the category channel that the currently exported channel belongs to. (Thanks [@rtm516](https://github.com/rtm516))
|
|
||||||
- [JSON] Fixed an issue where user discriminator was written without leading zeroes. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- [JSON] Fixed an issue where the application sometimes crashed with an error saying `']' invalid without a matching open`, which was just a validation message that masked the actual error behind the failure. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- Fixed an issue where progress was not reported correctly if the channel didn't have any messages in the specified time range.
|
|
||||||
|
|
||||||
## v2.26.1 (06-Feb-2021)
|
|
||||||
|
|
||||||
- [CLI] Added support for file name templates, which allow you to dynamically generate output file names based on channel and guild metadata. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- Fixed an issue where the application sometimes crashed with `Invalid snowflake` message when exporting chat logs that contained invalid or outdated mentions. (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
|
|
||||||
## v2.26 (29-Dec-2020)
|
|
||||||
|
|
||||||
- [HTML] Added support for replies. (Thanks [@Sanqui](https://github.com/Sanqui))
|
|
||||||
- [HTML] Improved styling of non-media attachments (regular files, i.e. not video, audio, or image). (Thanks [@Lucas LaBuff](https://github.com/96-LB))
|
|
||||||
- [HTML] Improved initial export performance.
|
|
||||||
- [JSON] Relaxed escaping rules for unicode characters. (Thanks [@Sanqui](https://github.com/Sanqui))
|
|
||||||
- [JSON] Added support for replies. (Thanks [@Sanqui](https://github.com/Sanqui))
|
|
||||||
- [CLI] Added channel names to errors shown on failures when exporting multiple channels. (Thanks [@Sanqui](https://github.com/Sanqui))
|
|
||||||
- [CLI] Added support for passing message IDs (snowflakes) to `--after` and `--before` options. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- Files downloaded by the "download referenced media" option now have their dates set according to the `Last-Modified` header provided by Discord CDN. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- Fixed an issue where the application sometimes crashed with `NullReferenceException` when retrying a failed HTTP request.
|
|
||||||
- Migrated to Discord API v8.
|
|
||||||
|
|
||||||
## v2.25 (23-Nov-2020)
|
|
||||||
|
|
||||||
- [JSON] Added `mentions` property to the output. This contains users referenced inside the message text, but doesn't include mentions in embeds. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- [HTML] Added better previews for attached video and audio. They are now rendered using a browser native player element. The actual file path can still be retrieved by right clicking and selecting "Copy file path". (Thanks [@sas41](https://github.com/sas41))
|
|
||||||
- [CLI] Fixed an issue where using `--media` option without providing a rooted path via `--output` option triggered an error.
|
|
||||||
- [CLI] Fixed an issue where using `--reuse-media` option without also providing `--media` option was accepted, but didn't actually do anything. Now this produces an error instead. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
|
|
||||||
## v2.24 (24-Oct-2020)
|
|
||||||
|
|
||||||
- [CLI] Updated to [CliFx v1.5](https://github.com/Tyrrrz/CliFx), which brings some UX improvements.
|
|
||||||
- [GUI] Added dark mode, which can be enabled in settings. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- [GUI] Improved the UX in a few minor places.
|
|
||||||
- [JSON] Added `embed.color` property to the output. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- Added additional date formats: `unix` to write dates as a unix timestamp and `unixms` for the milliseconds version. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- Added retry policy for downloading media content. This is mostly a workaround for transient failures that sometimes may occur when downloading assets referenced from embeds. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
- Added an option to reuse already downloaded media to avoid redundant network requests. It can be enabled in settings in GUI, or by passing `--reuse-media` in CLI. To facilitate this feature, the file name strategy has been changed as well -- now instead of relying on the original file name and adding `(n)` to the end in case of duplicates, a URL hash is injected in every file name. This also means that when the "reuse media" option is disabled, existing files inside the media directory may be overwritten. (Thanks [@Andrew Kolos](https://github.com/andrewkolos))
|
|
||||||
|
|
||||||
## v2.23 (14-Sep-2020)
|
|
||||||
|
|
||||||
- [CLI] Added a command to export all channels across all servers. Use `exportall` to do it. (Thanks [@wyattscarpenter](https://github.com/wyattscarpenter))
|
|
||||||
- [HTML] Fixed an issue where Whitney fonts were not being loaded properly, causing the browser to fall back to Helvetica.
|
|
||||||
- Fixed an issue where self-contained export crashed occasionally. This usually happened when the server hosting the file did not serve the stream properly. Such files are now ignored after the first failed attempt.
|
|
||||||
|
|
||||||
## v2.22 (12-Aug-2020)
|
|
||||||
|
|
||||||
- [GUI] Improved the channel list by adding collapsible category groups. (Thanks [@CarJem Generations](https://github.com/CarJem))
|
|
||||||
- [GUI] Improved exporting options by adding a set of controls that can be used to limit the date range of the export down to minutes. Previously it was only possible to configure the date range without the time component. (Thanks [@CarJem Generations](https://github.com/CarJem))
|
|
||||||
- [HTML] Fixed an issue where the export didn't reflect changes in nicknames between messages sent by bots. This affected chat logs that contained interactions with the Tupperbox bot. (Thanks [@CarJem Generations](https://github.com/CarJem))
|
|
||||||
- [CLI] Fixed an issue where the application crashed if there were two environment variables defined that had the same name but in different case.
|
|
||||||
|
|
||||||
## v2.21.2 (30-Jul-2020)
|
|
||||||
|
|
||||||
- [GUI] When copy-pasting token, any surrounding spaces are now discarded, in addition to double quotes.
|
|
||||||
- [HTML] Changed underlying templating engine to provide higher performance and better error messages. New templating engine adds a small cold start, but any export after the first should be faster.
|
|
||||||
- Changed naming schema for downloaded media so that it follows `<original filename> (nn)` format rather than `<original filename>-salt`.
|
|
||||||
- [HTML] Fixed an issue where downloaded media was sometimes inaccessible due to reserved characters appearing in the URL.
|
|
||||||
- Fixed an issue where the application crashed when trying to download media with a file name that exceeds system's maximum allowed length.
|
|
||||||
- Fixed an issue where the application crashed when trying to download media with illegal characters in the file name.
|
|
||||||
|
|
||||||
## v2.21.1 (19-Jul-2020)
|
|
||||||
|
|
||||||
- Fixed an issue where the export crashed if an embedded image has been deleted. Such media files are now ignored.
|
|
||||||
- Changed the naming convention for downloaded media files so that the original file names are used when possible.
|
|
||||||
|
|
||||||
## v2.21 (18-Jul-2020)
|
|
||||||
|
|
||||||
- Added a new option that enables self-contained exports for all output formats. You can turn it on in the export setup dialog in GUI or using the `--media` option in CLI. When using this, the application will additionally download any media content directly referenced from the exported file instead of linking back to Discord CDN. The files which are downloaded include: guild icons, user avatars, attachments, embedded images, reaction emoji. Note that only files which are actually referenced by the export are downloaded, which means that, for example, user avatars will not be downloaded when using plain text export format. This option is not meant to enable complete offline viewing for HTML exports, but rather to make it easier to archive media content that may eventually get deleted from Discord servers. Also keep in mind that this option may make the export drastically slower and the total file size larger.
|
|
||||||
- Changed "discordapp.com" to "discord.com" where applicable as Discord is migrating to a new domain. CDN will remain on "cdn.discordapp.com" for the foreseeable future.
|
|
||||||
|
|
||||||
Note that all existing and current HTML exports will likely not render accurately because Discord enabled CORS for their font resources, which prevents them from loading locally. Please refer to [issue #322](https://github.com/Tyrrrz/DiscordChatExporter/issues/322) for discussion on this topic.
|
|
||||||
|
|
||||||
## v2.20 (27-Apr-2020)
|
|
||||||
|
|
||||||
- [CLI] Added environment variables as fallback for `--token` and `--bot` options. They are `DISCORD_TOKEN` and `DISCORD_TOKEN_BOT` respectively.
|
|
||||||
- [GUI] Fixed a crash that occurred if the application was closed in the middle of an auto-update.
|
|
||||||
- [GUI] Added a link to project's wiki in the usage guide.
|
|
||||||
- [HTML] Added full spoiler support for text and images. To spoil the hidden content you now need to click on it, similarly to how it works in Discord. (Thanks [@FM-96](https://github.com/FM-96))
|
|
||||||
- [HTML] Updated grammar for consecutive single-line quotes. Previously they appeared separately, now they're grouped together as if it was one multi-line quote instead.
|
|
||||||
- [HTML] Fixed an issue where messages sent by the same bot but with different usernames were grouped together when they shouldn't be.
|
|
||||||
- [HTML] Updated grammar for single-line code blocks to accept double backticks as synonymous with single backticks. This change makes code blocks appear the same, whether they were inserted manually or using Discord's buggy markdown preview mode.
|
|
||||||
- [HTML] Fixed styling inconsistencies and other minor issues.
|
|
||||||
- [TXT/JSON] Fixed an issue where markdown was not parsed correctly in embed fields.
|
|
||||||
- [HTML] Changed markdown formatting in embeds so it follows the same set of rules as in Discord.
|
|
||||||
- Added channel category to the default file name used when exporting chat logs.
|
|
||||||
- [HTML/TXT/JSON] Added channel category to exported metadata.
|
|
||||||
- [CLI] Updated commands to also show channel category as well as channel name wherever relevant.
|
|
||||||
- Starting with this release, Docker images will have new tags: `stable` for latest stable release and `2.20` for a specific version.
|
|
||||||
|
|
||||||
## v2.19 (26-Mar-2020)
|
|
||||||
|
|
||||||
- Added parallel exporting. This option allows you to export multiple channels faster by doing it in parallel. You can configure the parallel limit in settings (GUI) or with the `--parallel` option (CLI). Default value is `1`, which means there is no parallelization. Warning: be careful when using this option, as this will result in higher volume of concurrent HTTP requests sent to Discord, which might get you flagged. Use at your own risk.
|
|
||||||
- [HTML] Added support for user colors. User names are now appropriately colored according to the assigned guild roles.
|
|
||||||
- [HTML] Added support for nicknames. User names are replaced with nicknames where it's applicable. It's still possible to see the full user name by hovering your mouse over the nickname.
|
|
||||||
- [HTML] Improved styling for mentions to bring it more in line with how it looks in Discord.
|
|
||||||
|
|
||||||
## v2.18 (04-Feb-2020)
|
|
||||||
|
|
||||||
- Added JSON export format. It's a structured data format which is easy to parse. If you're using DiscordChatExporter to export chat logs for further ingestion by another tool, this is most likely the format you will want to use.
|
|
||||||
- [GUI] You can now quickly jump to a specific channel in a list. For example, if you want to jump to a channel named "General", you can simply press the 'g' key in the channel list view. You can also press 'g', 'e' and 'n' in quick succession which will jump to the next channel that starts with "gen". This mechanic is consistent with other Windows applications.
|
|
||||||
- [CLI] Improved help text screen.
|
|
||||||
|
|
||||||
## v2.17 (12-Jan-2020)
|
|
||||||
|
|
||||||
- Fixed an issue where an empty file was produced when exporting a channel with no messages (for specified period). With the new behavior, no file will be created and instead a message will be shown to the user informing of the failure.
|
|
||||||
- [HTML/TXT] Added message count to the bottom of the file. This number shows how many messages were exported as part of the current file. Prior to 2.16 this number was present along with the rest of the metadata at the top, then removed due to changes in the exporter, and now brought back at the end of the file instead.
|
|
||||||
- [HTML] Fixed an issue where some emoji were not properly rendered.
|
|
||||||
- [GUI] Added a setting that lets you configure whether to remember the last used token. Previously it was the default behavior, but now you can disable it if you don't want the token persisted on your system.
|
|
||||||
|
|
||||||
## v2.16 (08-Dec-2019)
|
|
||||||
|
|
||||||
- Migrated from .NET Framework to .NET Core. To run this and future versions of DiscordChatExporter you will need [.NET Core runtime for desktop apps](https://dotnet.microsoft.com/download/dotnet-core/3.1/runtime) (for GUI/CLI version on Windows) or [.NET Core base runtime](https://dotnet.microsoft.com/download/dotnet-core/3.1) (for CLI version on Windows, Linux or macOS).
|
|
||||||
- Reworked the exporter engine to render output using streaming data source. This means that only a very small portion of messages are cached in memory when exporting. In other words, you are only limited by storage space and not how much RAM you have, so you can now export terabytes of chat logs without hitting out of memory exceptions. I still recommend using partitions if you're exporting very large chat logs (250k+ messages) to HTML, unless you want your computer to catch fire when you try to open the export in browser.
|
|
||||||
- Changed how partitioned files are named, due to the fact that total number of partitions is no longer known ahead of time.
|
|
||||||
- Added a warning about automating user accounts to the usage guide in both GUI and CLI versions.
|
|
||||||
- Added support for announcement (news) channels. You will now be able to see them in the list and export them.
|
|
||||||
- Fixed various issues that resulted in exceptions during export process.
|
|
||||||
- [HTML/TXT] Removed message count from the metadata. Due to the fact that the messages are exported as they are streamed, total number of messages is not known ahead of time.
|
|
||||||
- [HTML] Changed default color of the embed color pill to match the theme.
|
|
||||||
- [HTML] Changed emoji parser to be less greedy. As a result it should match fewer character sequences that look like emoji but really aren't, but on the other hand it might miss some actual emoji. This means that some standard emoji (i.e. not custom server emoji) may not look like in Discord. This is a compromise I'm willing to take because detecting emoji in text is really hard to get right and not worth it at all.
|
|
||||||
- [HTML] Some other minor styling adjustments.
|
|
||||||
- [CSV] Replaced semicolons (;) with (,) as separators.
|
|
||||||
|
|
||||||
Please note that CSV export is most likely not going to receive future updates and will remain only as an option for those who wish to use it for text analysis. In other words, it won't contain any of the rich media features like embeds. If you're currently using CSV as a structured output to feed into your program, JSON output will replace that in the future.
|
|
||||||
|
|
||||||
## v2.15 (15-Sep-2019)
|
|
||||||
|
|
||||||
- Improved markdown parser and made it even faster for non-HTML formats.
|
|
||||||
- [HTML] Added support for block quotes.
|
|
||||||
- [HTML] Links pointing to a Discord message will now navigate to the linked message inside exported chat log if it's there.
|
|
||||||
- [HTML] Updated light theme to match how it looks in Discord after recent changes.
|
|
||||||
- [HTML] Added indication for when a message is pinned. Pinned messages now have a tinted background.
|
|
||||||
- [HTML] Fixed an issue where multiline code blocks sometimes had incorrect formatting applied to them.
|
|
||||||
- [TXT] Added indication for when a message is pinned. Pinned messages now have `(pinned)` next to timestamp and author.
|
|
||||||
- [CSV] Added message author's user ID to output.
|
|
||||||
- [GUI] Streamlined auto-update process a bit.
|
|
||||||
- [GUI] Added some tooltips.
|
|
||||||
|
|
||||||
## v2.14 (15-Jun-2019)
|
|
||||||
|
|
||||||
- [TXT] Added support for embeds.
|
|
||||||
- [TXT] Added support for reactions.
|
|
||||||
- [CSV] Added support for reactions.
|
|
||||||
- [TXT] Changed how attachments are rendered.
|
|
||||||
|
|
||||||
## v2.13.1 (06-Jun-2019)
|
|
||||||
|
|
||||||
- Fixed an issue where the app sometimes crashed when exporting due to `System.InvalidCastException`.
|
|
||||||
- [HTML] Added `data-user-id` attribute to `span.chatlog__author-name`. The value of this attribute is author's Discord user ID.
|
|
||||||
|
|
||||||
## v2.13 (15-May-2019)
|
|
||||||
|
|
||||||
- Updated usage instructions.
|
|
||||||
- [HTML] Added BOT tags to messages posted by bots.
|
|
||||||
- [GUI] UI will now be disabled when exporting.
|
|
||||||
- [GUI] Notification informing that the export has completed will now appear after all exports have completed, instead of each of them separately.
|
|
||||||
|
|
||||||
## v2.12.1 (12-Apr-2019)
|
|
||||||
|
|
||||||
- [GUI] Fixed an issue where the app crashed when trying to export multiple channels.
|
|
||||||
- [HTML] Fixed an issue where some of the emoji were rendered via Twemoji while Discord renders them as plain text.
|
|
||||||
- [HTML] Fixed an issue where emoji weren't jumbo if there were more than one of them.
|
|
||||||
|
|
||||||
## v2.12 (11-Apr-2019)
|
|
||||||
|
|
||||||
- Improved markdown parsing performance which speeds up the final stage of exporting by around 4.5 times.
|
|
||||||
- Improved performance when exporting as PlainText or CSV.
|
|
||||||
- [GUI] Fixed an issue where the app would freeze up and report as "not responding" during the final stage of exporting.
|
|
||||||
- [CLI] Fixed an issue where it would say "Completed" after exporting a chat log, even if the process failed.
|
|
||||||
|
|
||||||
## v2.11 (14-Mar-2019)
|
|
||||||
|
|
||||||
- [HTML] Added syntax highlighting for multiline code blocks via Highlight.js.
|
|
||||||
- Added retry policy for all 5xx status codes to prevent random crashes.
|
|
||||||
|
|
||||||
## v2.10.2 (10-Mar-2019)
|
|
||||||
|
|
||||||
- [HTML] Updated message grouping algorithm to make it the same as in Discord. Removed "message group limit" setting and parameter.
|
|
||||||
- [HTML] Added small margin at the end of the chatlog so it doesn't look like it was truncated.
|
|
||||||
- [CLI] Fixed an issue where the app would crash if stdout was redirected. Progress will not be reported in such cases.
|
|
||||||
|
|
||||||
## v2.10.1 (06-Mar-2019)
|
|
||||||
|
|
||||||
- [HTML] Fixed an issue where multiple emoji on a single line would get rendered as one emoji.
|
|
||||||
- [HTML] Fixed an issue where an open square bracket character would incorrectly render as an emoji.
|
|
||||||
- [HTML] Added alt text to emoji images so that they will be rendered using default font when Twemoji images are not available.
|
|
||||||
|
|
||||||
## v2.10 (03-Mar-2019)
|
|
||||||
|
|
||||||
- [HTML] Reworked the entire markdown parsing engine which fixes numerous rendering inconsistencies (over 15 issues fixed).
|
|
||||||
- [HTML] Added support for animated emoji.
|
|
||||||
- [HTML] Standard emoji are now rendered using Twemoji, the same image set that Discord uses.
|
|
||||||
- [HTML] Fixed an issue where video attachments would render incorrectly.
|
|
||||||
- [HTML] Minor fixes in styling.
|
|
||||||
- [GUI] Aggregated export progress is now shown in the taskbar.
|
|
||||||
- [GUI] Checkmarks are now displayed next to channels that are selected.
|
|
||||||
- [CLI] Added progress reporting when exporting chat logs.
|
|
||||||
|
|
||||||
## v2.9.1 (10-Feb-2019)
|
|
||||||
|
|
||||||
- Fixed an issue where some of the last messages in a channel would sometimes not get exported.
|
|
||||||
|
|
||||||
## v2.9 (09-Feb-2019)
|
|
||||||
|
|
||||||
- Added categories to channel list in GUI. Channels are now also grouped by category.
|
|
||||||
- Added ability to export multiple channels at once in GUI by selecting them with shift or ctrl keys.
|
|
||||||
- Added CLI command to export all available channels in a guild (`exportguild`).
|
|
||||||
- Added CLI command to export all direct message channels (`exportdm`).
|
|
||||||
- Added retry policy for 503 status code errors to prevent random crashes.
|
|
||||||
- Changed how channels are exported in GUI. Now you need to select them first and then click a button to export. You can also double click a single channel to export it as before.
|
|
||||||
- Improved default file name generation by adding date ranges and channel ID to the file name.
|
|
||||||
- Improved naming of files exported with partitioning.
|
|
||||||
- Improved usage instructions.
|
|
||||||
- Improved GUI layout and styling.
|
|
||||||
- Fixed an issue where dialogs would sometimes appear over other windows.
|
|
||||||
- Fixed an issue where launching DiscordChatExporter from Windows Start Menu would make it crash.
|
|
||||||
|
|
||||||
## v2.8 (03-Nov-2018)
|
|
||||||
|
|
||||||
- Added support for partitioning which lets you split the output into multiple files by setting the partition message limit (`-p` parameter for CLI).
|
|
||||||
- Exported file will no longer open automatically on completion.
|
|
||||||
- Reduced amount of memory used during exporting.
|
|
||||||
- Disabled message grouping in PlainText export.
|
|
||||||
- Improved encoding of newlines in CSV export.
|
|
||||||
- Improved error messages in the GUI app during crashes.
|
|
||||||
|
|
||||||
## v2.7 (14-Sep-2018)
|
|
||||||
|
|
||||||
- Updated instructions on how to obtain the user token.
|
|
||||||
- Expanded CLI with new commands: `channels` (get a list of channels in a guild), `dm` (get a list of DM channels), `guilds` (get a list of guilds), on top of `export` (export chatlog).
|
|
||||||
- Improved help text and error messages in CLI.
|
|
||||||
- In CLI, the file name will be automatically generated if the provided output file path is a directory.
|
|
||||||
|
|
||||||
## v2.6 (25-Jul-2018)
|
|
||||||
|
|
||||||
- Added support for bot tokens as an alternative to user tokens. For GUI, use the button in the top-left to switch between user and bot token. For CLI, pass the `--bot` switch to indicate that the given token is a bot token.
|
|
||||||
- Added support for animated avatars.
|
|
||||||
|
|
||||||
## v2.5.1 (01-Jul-2018)
|
|
||||||
|
|
||||||
- Fixed a bug that would prevent timestamps from rendering properly in CSV and PlainText exports.
|
|
||||||
- Fixed incorrect layout in CSV export.
|
|
||||||
- Improved readability of PlainText export.
|
|
||||||
|
|
||||||
## v2.5 (28-Jun-2018)
|
|
||||||
|
|
||||||
- Added support for embeds and webhooks (HTML only).
|
|
||||||
- Implemented progress reporting when downloading messages.
|
|
||||||
- Added support for reactions (HTML only).
|
|
||||||
- Selected date range is now shown in the export (HTML and PlainText).
|
|
||||||
- Added placeholders for guild icons to display while the icons are loading.
|
|
||||||
- Added support for jumbo emoji (custom emoji only).
|
|
||||||
- Added basic retry policy for 429 error responses.
|
|
||||||
- Added validation for from/to dates in the UI which prevents choosing invalid date ranges.
|
|
||||||
- Added an error message when trying to export a deleted channel.
|
|
||||||
|
|
||||||
## v2.4.1 (15-Apr-2018)
|
|
||||||
|
|
||||||
- Added CSV export format.
|
|
||||||
- Channels are now ordered by name in the UI.
|
|
||||||
- Exported file is now always opened upon completion.
|
|
||||||
|
|
||||||
## v2.4 (08-Apr-2018)
|
|
||||||
|
|
||||||
- Added channel topic to output.
|
|
||||||
- Added a command-line interface alternative to the current graphical user interface.
|
|
||||||
- Implemented application auto-update (can be disabled in settings).
|
|
||||||
- Improved some GUI elements and replaced some dialogs with notifications.
|
|
||||||
- Fixed a lot of issues with the markdown processor.
|
|
||||||
- Fixed DM group chats that have a custom name being shown as blank in the list.
|
|
||||||
|
|
||||||
## v2.3 (27-Oct-2017)
|
|
||||||
|
|
||||||
- Improved message date filtering, it's now marginally faster.
|
|
||||||
- Fixed underscores not recognized as italics in markdown.
|
|
||||||
- Added support for custom emoji.
|
|
||||||
- Added support for user and role mentions.
|
|
||||||
- Added support for channel mentions.
|
|
||||||
- Fixed text in pre blocks not being wrapped correctly.
|
|
||||||
- Added workaround for non-default message types.
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Version>2.38</Version>
|
<Version>999.9.9-dev</Version>
|
||||||
<Company>Tyrrrz</Company>
|
<Company>Tyrrrz</Company>
|
||||||
<Copyright>Copyright (c) Oleksii Holub</Copyright>
|
<Copyright>Copyright (c) Oleksii Holub</Copyright>
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>preview</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<WarningsAsErrors>nullable</WarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -8,22 +8,21 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||||
<None Include="*.secret" CopyToOutputDirectory="PreserveNewest" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AngleSharp" Version="1.0.1" />
|
<PackageReference Include="AngleSharp" Version="1.1.2" />
|
||||||
<PackageReference Include="FluentAssertions" Version="6.10.0" />
|
<PackageReference Include="coverlet.collector" Version="6.0.2" PrivateAssets="all" />
|
||||||
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.1" PrivateAssets="all" />
|
<PackageReference Include="CSharpier.MsBuild" Version="0.28.2" PrivateAssets="all" />
|
||||||
|
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||||
|
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" PrivateAssets="all" />
|
||||||
<PackageReference Include="JsonExtensions" Version="1.2.0" />
|
<PackageReference Include="JsonExtensions" Version="1.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||||
<PackageReference Include="ReflectionMagic" Version="4.1.0" />
|
<PackageReference Include="xunit" Version="2.8.0" />
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0" PrivateAssets="all" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all" />
|
|
||||||
<PackageReference Include="coverlet.collector" Version="3.2.0" PrivateAssets="all" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ public static class ChannelIds
|
|||||||
public static Snowflake SelfContainedTestCases { get; } = Snowflake.Parse("887441432678379560");
|
public static Snowflake SelfContainedTestCases { get; } = Snowflake.Parse("887441432678379560");
|
||||||
|
|
||||||
public static Snowflake StickerTestCases { get; } = Snowflake.Parse("939668868253769729");
|
public static Snowflake StickerTestCases { get; } = Snowflake.Parse("939668868253769729");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,16 @@ namespace DiscordChatExporter.Cli.Tests.Infra;
|
|||||||
|
|
||||||
public static class ExportWrapper
|
public static class ExportWrapper
|
||||||
{
|
{
|
||||||
private static readonly AsyncKeyedLocker<string> Locker = new(o =>
|
private static readonly AsyncKeyedLocker<string> Locker =
|
||||||
{
|
new(o =>
|
||||||
o.PoolSize = 20;
|
{
|
||||||
o.PoolInitialFill = 1;
|
o.PoolSize = 20;
|
||||||
});
|
o.PoolInitialFill = 1;
|
||||||
|
});
|
||||||
|
|
||||||
private static readonly string DirPath = Path.Combine(
|
private static readonly string DirPath = Path.Combine(
|
||||||
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Directory.GetCurrentDirectory(),
|
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
||||||
|
?? Directory.GetCurrentDirectory(),
|
||||||
"ExportCache"
|
"ExportCache"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -36,9 +38,7 @@ public static class ExportWrapper
|
|||||||
{
|
{
|
||||||
Directory.Delete(DirPath, true);
|
Directory.Delete(DirPath, true);
|
||||||
}
|
}
|
||||||
catch (DirectoryNotFoundException)
|
catch (DirectoryNotFoundException) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Directory.CreateDirectory(DirPath);
|
Directory.CreateDirectory(DirPath);
|
||||||
}
|
}
|
||||||
@@ -48,32 +48,31 @@ public static class ExportWrapper
|
|||||||
var fileName = channelId.ToString() + '.' + format.GetFileExtension();
|
var fileName = channelId.ToString() + '.' + format.GetFileExtension();
|
||||||
var filePath = Path.Combine(DirPath, fileName);
|
var filePath = Path.Combine(DirPath, fileName);
|
||||||
|
|
||||||
// Lock separately for each channel and format
|
using var _ = await Locker.LockAsync(filePath);
|
||||||
using (await Locker.LockAsync(filePath))
|
using var console = new FakeConsole();
|
||||||
{
|
|
||||||
// Perform export only if it hasn't been done before
|
|
||||||
if (!File.Exists(filePath))
|
|
||||||
{
|
|
||||||
await new ExportChannelsCommand
|
|
||||||
{
|
|
||||||
Token = Secrets.DiscordToken,
|
|
||||||
ChannelIds = new[] { channelId },
|
|
||||||
ExportFormat = format,
|
|
||||||
OutputPath = filePath
|
|
||||||
}.ExecuteAsync(new FakeConsole());
|
|
||||||
}
|
|
||||||
|
|
||||||
return await File.ReadAllTextAsync(filePath);
|
// Perform the export only if it hasn't been done before
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
await new ExportChannelsCommand
|
||||||
|
{
|
||||||
|
Token = Secrets.DiscordToken,
|
||||||
|
ChannelIds = [channelId],
|
||||||
|
ExportFormat = format,
|
||||||
|
OutputPath = filePath,
|
||||||
|
Locale = "en-US",
|
||||||
|
IsUtcNormalizationEnabled = true
|
||||||
|
}.ExecuteAsync(console);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return await File.ReadAllTextAsync(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async ValueTask<IHtmlDocument> ExportAsHtmlAsync(Snowflake channelId) => Html.Parse(
|
public static async ValueTask<IHtmlDocument> ExportAsHtmlAsync(Snowflake channelId) =>
|
||||||
await ExportAsync(channelId, ExportFormat.HtmlDark)
|
Html.Parse(await ExportAsync(channelId, ExportFormat.HtmlDark));
|
||||||
);
|
|
||||||
|
|
||||||
public static async ValueTask<JsonElement> ExportAsJsonAsync(Snowflake channelId) => Json.Parse(
|
public static async ValueTask<JsonElement> ExportAsJsonAsync(Snowflake channelId) =>
|
||||||
await ExportAsync(channelId, ExportFormat.Json)
|
Json.Parse(await ExportAsync(channelId, ExportFormat.Json));
|
||||||
);
|
|
||||||
|
|
||||||
public static async ValueTask<string> ExportAsPlainTextAsync(Snowflake channelId) =>
|
public static async ValueTask<string> ExportAsPlainTextAsync(Snowflake channelId) =>
|
||||||
await ExportAsync(channelId, ExportFormat.PlainText);
|
await ExportAsync(channelId, ExportFormat.PlainText);
|
||||||
@@ -81,56 +80,57 @@ public static class ExportWrapper
|
|||||||
public static async ValueTask<string> ExportAsCsvAsync(Snowflake channelId) =>
|
public static async ValueTask<string> ExportAsCsvAsync(Snowflake channelId) =>
|
||||||
await ExportAsync(channelId, ExportFormat.Csv);
|
await ExportAsync(channelId, ExportFormat.Csv);
|
||||||
|
|
||||||
public static async ValueTask<IReadOnlyList<IElement>> GetMessagesAsHtmlAsync(Snowflake channelId) =>
|
public static async ValueTask<IReadOnlyList<IElement>> GetMessagesAsHtmlAsync(
|
||||||
(await ExportAsHtmlAsync(channelId))
|
Snowflake channelId
|
||||||
.QuerySelectorAll("[data-message-id]")
|
) => (await ExportAsHtmlAsync(channelId)).QuerySelectorAll("[data-message-id]").ToArray();
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
public static async ValueTask<IReadOnlyList<JsonElement>> GetMessagesAsJsonAsync(Snowflake channelId) =>
|
public static async ValueTask<IReadOnlyList<JsonElement>> GetMessagesAsJsonAsync(
|
||||||
(await ExportAsJsonAsync(channelId))
|
Snowflake channelId
|
||||||
.GetProperty("messages")
|
) => (await ExportAsJsonAsync(channelId)).GetProperty("messages").EnumerateArray().ToArray();
|
||||||
.EnumerateArray()
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
public static async ValueTask<IElement> GetMessageAsHtmlAsync(Snowflake channelId, Snowflake messageId)
|
public static async ValueTask<IElement> GetMessageAsHtmlAsync(
|
||||||
|
Snowflake channelId,
|
||||||
|
Snowflake messageId
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var message = (await GetMessagesAsHtmlAsync(channelId))
|
var message = (await GetMessagesAsHtmlAsync(channelId)).SingleOrDefault(e =>
|
||||||
.SingleOrDefault(e =>
|
string.Equals(
|
||||||
string.Equals(
|
e.GetAttribute("data-message-id"),
|
||||||
e.GetAttribute("data-message-id"),
|
messageId.ToString(),
|
||||||
messageId.ToString(),
|
StringComparison.OrdinalIgnoreCase
|
||||||
StringComparison.OrdinalIgnoreCase
|
)
|
||||||
)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (message is null)
|
if (message is null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"Message '{messageId}' does not exist in the export of channel '{channelId}'."
|
$"Message #{messageId} not found in the export of channel #{channelId}."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async ValueTask<JsonElement> GetMessageAsJsonAsync(Snowflake channelId, Snowflake messageId)
|
public static async ValueTask<JsonElement> GetMessageAsJsonAsync(
|
||||||
|
Snowflake channelId,
|
||||||
|
Snowflake messageId
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var message = (await GetMessagesAsJsonAsync(channelId))
|
var message = (await GetMessagesAsJsonAsync(channelId)).SingleOrDefault(j =>
|
||||||
.SingleOrDefault(j =>
|
string.Equals(
|
||||||
string.Equals(
|
j.GetProperty("id").GetString(),
|
||||||
j.GetProperty("id").GetString(),
|
messageId.ToString(),
|
||||||
messageId.ToString(),
|
StringComparison.OrdinalIgnoreCase
|
||||||
StringComparison.OrdinalIgnoreCase
|
)
|
||||||
)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (message.ValueKind == JsonValueKind.Undefined)
|
if (message.ValueKind == JsonValueKind.Undefined)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"Message '{messageId}' does not exist in the export of channel '{channelId}'."
|
$"Message #{messageId} not found in the export of channel #{channelId}."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ internal static class Secrets
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
public static string DiscordToken =>
|
public static string DiscordToken =>
|
||||||
Configuration["DISCORD_TOKEN"] ??
|
Configuration["DISCORD_TOKEN"]
|
||||||
throw new InvalidOperationException("Discord token not provided for tests.");
|
?? throw new InvalidOperationException("Discord token not provided for tests.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,22 +8,24 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class CsvContentSpecs
|
public class CsvContentSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_are_exported_correctly()
|
public async Task I_can_export_a_channel_in_the_CSV_format()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var document = await ExportWrapper.ExportAsCsvAsync(ChannelIds.DateRangeTestCases);
|
var document = await ExportWrapper.ExportAsCsvAsync(ChannelIds.DateRangeTestCases);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
document.Should().ContainAll(
|
document
|
||||||
"Tyrrrz#5447",
|
.Should()
|
||||||
"Hello world",
|
.ContainAll(
|
||||||
"Goodbye world",
|
"tyrrrz",
|
||||||
"Foo bar",
|
"Hello world",
|
||||||
"Hurdle Durdle",
|
"Goodbye world",
|
||||||
"One",
|
"Foo bar",
|
||||||
"Two",
|
"Hurdle Durdle",
|
||||||
"Three",
|
"One",
|
||||||
"Yeet"
|
"Two",
|
||||||
);
|
"Three",
|
||||||
|
"Yeet"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class DateRangeSpecs
|
public class DateRangeSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_filtered_after_specific_date_only_include_messages_sent_after_that_date()
|
public async Task I_can_filter_the_export_to_only_include_messages_sent_after_the_specified_date()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var after = new DateTimeOffset(2021, 07, 24, 0, 0, 0, TimeSpan.Zero);
|
var after = new DateTimeOffset(2021, 07, 24, 0, 0, 0, TimeSpan.Zero);
|
||||||
@@ -27,15 +27,14 @@ public class DateRangeSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||||
ExportFormat = ExportFormat.Json,
|
ExportFormat = ExportFormat.Json,
|
||||||
OutputPath = file.Path,
|
OutputPath = file.Path,
|
||||||
After = Snowflake.FromDate(after)
|
After = Snowflake.FromDate(after)
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var timestamps = Json
|
var timestamps = Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.GetProperty("messages")
|
.GetProperty("messages")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(j => j.GetProperty("timestamp").GetDateTimeOffset())
|
.Select(j => j.GetProperty("timestamp").GetDateTimeOffset())
|
||||||
@@ -43,25 +42,26 @@ public class DateRangeSpecs
|
|||||||
|
|
||||||
timestamps.All(t => t > after).Should().BeTrue();
|
timestamps.All(t => t > after).Should().BeTrue();
|
||||||
|
|
||||||
timestamps.Should().BeEquivalentTo(new[]
|
timestamps
|
||||||
{
|
.Should()
|
||||||
new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero),
|
.BeEquivalentTo(
|
||||||
new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero),
|
[
|
||||||
new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero),
|
new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero),
|
||||||
new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero),
|
new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero),
|
||||||
new DateTimeOffset(2021, 09, 08, 14, 26, 35, TimeSpan.Zero)
|
new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero),
|
||||||
}, o =>
|
new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero),
|
||||||
{
|
new DateTimeOffset(2021, 09, 08, 14, 26, 35, TimeSpan.Zero)
|
||||||
return o
|
],
|
||||||
.Using<DateTimeOffset>(ctx =>
|
o =>
|
||||||
ctx.Subject.Should().BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
o.Using<DateTimeOffset>(ctx =>
|
||||||
)
|
ctx.Subject.Should().BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
||||||
.WhenTypeIs<DateTimeOffset>();
|
)
|
||||||
});
|
.WhenTypeIs<DateTimeOffset>()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_filtered_before_specific_date_only_include_messages_sent_before_that_date()
|
public async Task I_can_filter_the_export_to_only_include_messages_sent_before_the_specified_date()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var before = new DateTimeOffset(2021, 07, 24, 0, 0, 0, TimeSpan.Zero);
|
var before = new DateTimeOffset(2021, 07, 24, 0, 0, 0, TimeSpan.Zero);
|
||||||
@@ -71,15 +71,14 @@ public class DateRangeSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||||
ExportFormat = ExportFormat.Json,
|
ExportFormat = ExportFormat.Json,
|
||||||
OutputPath = file.Path,
|
OutputPath = file.Path,
|
||||||
Before = Snowflake.FromDate(before)
|
Before = Snowflake.FromDate(before)
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var timestamps = Json
|
var timestamps = Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.GetProperty("messages")
|
.GetProperty("messages")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(j => j.GetProperty("timestamp").GetDateTimeOffset())
|
.Select(j => j.GetProperty("timestamp").GetDateTimeOffset())
|
||||||
@@ -87,23 +86,24 @@ public class DateRangeSpecs
|
|||||||
|
|
||||||
timestamps.All(t => t < before).Should().BeTrue();
|
timestamps.All(t => t < before).Should().BeTrue();
|
||||||
|
|
||||||
timestamps.Should().BeEquivalentTo(new[]
|
timestamps
|
||||||
{
|
.Should()
|
||||||
new DateTimeOffset(2021, 07, 19, 13, 34, 18, TimeSpan.Zero),
|
.BeEquivalentTo(
|
||||||
new DateTimeOffset(2021, 07, 19, 15, 58, 48, TimeSpan.Zero),
|
[
|
||||||
new DateTimeOffset(2021, 07, 19, 17, 23, 58, TimeSpan.Zero)
|
new DateTimeOffset(2021, 07, 19, 13, 34, 18, TimeSpan.Zero),
|
||||||
}, o =>
|
new DateTimeOffset(2021, 07, 19, 15, 58, 48, TimeSpan.Zero),
|
||||||
{
|
new DateTimeOffset(2021, 07, 19, 17, 23, 58, TimeSpan.Zero)
|
||||||
return o
|
],
|
||||||
.Using<DateTimeOffset>(ctx =>
|
o =>
|
||||||
ctx.Subject.Should().BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
o.Using<DateTimeOffset>(ctx =>
|
||||||
)
|
ctx.Subject.Should().BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
||||||
.WhenTypeIs<DateTimeOffset>();
|
)
|
||||||
});
|
.WhenTypeIs<DateTimeOffset>()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_filtered_between_specific_dates_only_include_messages_sent_between_those_dates()
|
public async Task I_can_filter_the_export_to_only_include_messages_sent_between_the_specified_dates()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var after = new DateTimeOffset(2021, 07, 24, 0, 0, 0, TimeSpan.Zero);
|
var after = new DateTimeOffset(2021, 07, 24, 0, 0, 0, TimeSpan.Zero);
|
||||||
@@ -114,7 +114,7 @@ public class DateRangeSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||||
ExportFormat = ExportFormat.Json,
|
ExportFormat = ExportFormat.Json,
|
||||||
OutputPath = file.Path,
|
OutputPath = file.Path,
|
||||||
Before = Snowflake.FromDate(before),
|
Before = Snowflake.FromDate(before),
|
||||||
@@ -122,8 +122,7 @@ public class DateRangeSpecs
|
|||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var timestamps = Json
|
var timestamps = Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.GetProperty("messages")
|
.GetProperty("messages")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(j => j.GetProperty("timestamp").GetDateTimeOffset())
|
.Select(j => j.GetProperty("timestamp").GetDateTimeOffset())
|
||||||
@@ -131,19 +130,20 @@ public class DateRangeSpecs
|
|||||||
|
|
||||||
timestamps.All(t => t < before && t > after).Should().BeTrue();
|
timestamps.All(t => t < before && t > after).Should().BeTrue();
|
||||||
|
|
||||||
timestamps.Should().BeEquivalentTo(new[]
|
timestamps
|
||||||
{
|
.Should()
|
||||||
new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero),
|
.BeEquivalentTo(
|
||||||
new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero),
|
[
|
||||||
new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero),
|
new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero),
|
||||||
new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero)
|
new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero),
|
||||||
}, o =>
|
new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero),
|
||||||
{
|
new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero)
|
||||||
return o
|
],
|
||||||
.Using<DateTimeOffset>(ctx =>
|
o =>
|
||||||
ctx.Subject.Should().BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
o.Using<DateTimeOffset>(ctx =>
|
||||||
)
|
ctx.Subject.Should().BeCloseTo(ctx.Expectation, TimeSpan.FromSeconds(1))
|
||||||
.WhenTypeIs<DateTimeOffset>();
|
)
|
||||||
});
|
.WhenTypeIs<DateTimeOffset>()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
@@ -16,7 +17,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class FilterSpecs
|
public class FilterSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_filtered_by_text_only_include_messages_that_contain_that_text()
|
public async Task I_can_filter_the_export_to_only_include_messages_that_contain_the_specified_text()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
using var file = TempFile.Create();
|
using var file = TempFile.Create();
|
||||||
@@ -25,24 +26,23 @@ public class FilterSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
ChannelIds = [ChannelIds.FilterTestCases],
|
||||||
ExportFormat = ExportFormat.Json,
|
ExportFormat = ExportFormat.Json,
|
||||||
OutputPath = file.Path,
|
OutputPath = file.Path,
|
||||||
MessageFilter = MessageFilter.Parse("some text")
|
MessageFilter = MessageFilter.Parse("some text")
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Json
|
Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.GetProperty("messages")
|
.GetProperty("messages")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(j => j.GetProperty("content").GetString())
|
.Select(j => j.GetProperty("content").GetString())
|
||||||
.Should()
|
.Should()
|
||||||
.ContainSingle("Some random text");
|
.AllSatisfy(c => c.Contains("Some random text", StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_filtered_by_author_only_include_messages_sent_by_that_author()
|
public async Task I_can_filter_the_export_to_only_include_messages_that_were_sent_by_the_specified_author()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
using var file = TempFile.Create();
|
using var file = TempFile.Create();
|
||||||
@@ -51,24 +51,23 @@ public class FilterSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
ChannelIds = [ChannelIds.FilterTestCases],
|
||||||
ExportFormat = ExportFormat.Json,
|
ExportFormat = ExportFormat.Json,
|
||||||
OutputPath = file.Path,
|
OutputPath = file.Path,
|
||||||
MessageFilter = MessageFilter.Parse("from:Tyrrrz")
|
MessageFilter = MessageFilter.Parse("from:Tyrrrz")
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Json
|
Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.GetProperty("messages")
|
.GetProperty("messages")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(j => j.GetProperty("author").GetProperty("name").GetString())
|
.Select(j => j.GetProperty("author").GetProperty("name").GetString())
|
||||||
.Should()
|
.Should()
|
||||||
.AllBe("Tyrrrz");
|
.AllBe("tyrrrz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_filtered_by_content_only_include_messages_that_have_that_content()
|
public async Task I_can_filter_the_export_to_only_include_messages_that_contain_images()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
using var file = TempFile.Create();
|
using var file = TempFile.Create();
|
||||||
@@ -77,24 +76,23 @@ public class FilterSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
ChannelIds = [ChannelIds.FilterTestCases],
|
||||||
ExportFormat = ExportFormat.Json,
|
ExportFormat = ExportFormat.Json,
|
||||||
OutputPath = file.Path,
|
OutputPath = file.Path,
|
||||||
MessageFilter = MessageFilter.Parse("has:image")
|
MessageFilter = MessageFilter.Parse("has:image")
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Json
|
Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.GetProperty("messages")
|
.GetProperty("messages")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(j => j.GetProperty("content").GetString())
|
.Select(j => j.GetProperty("content").GetString())
|
||||||
.Should()
|
.Should()
|
||||||
.ContainSingle("This has image");
|
.AllSatisfy(c => c.Contains("This has image", StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_filtered_by_pin_only_include_messages_that_have_been_pinned()
|
public async Task I_can_filter_the_export_to_only_include_messages_that_have_been_pinned()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
using var file = TempFile.Create();
|
using var file = TempFile.Create();
|
||||||
@@ -103,24 +101,23 @@ public class FilterSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
ChannelIds = [ChannelIds.FilterTestCases],
|
||||||
ExportFormat = ExportFormat.Json,
|
ExportFormat = ExportFormat.Json,
|
||||||
OutputPath = file.Path,
|
OutputPath = file.Path,
|
||||||
MessageFilter = MessageFilter.Parse("has:pin")
|
MessageFilter = MessageFilter.Parse("has:pin")
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Json
|
Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.GetProperty("messages")
|
.GetProperty("messages")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(j => j.GetProperty("content").GetString())
|
.Select(j => j.GetProperty("content").GetString())
|
||||||
.Should()
|
.Should()
|
||||||
.ContainSingle("This is pinned");
|
.AllSatisfy(c => c.Contains("This is pinned", StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_filtered_by_mention_only_include_messages_that_have_that_mention()
|
public async Task I_can_filter_the_export_to_only_include_messages_that_contain_guild_invites()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
using var file = TempFile.Create();
|
using var file = TempFile.Create();
|
||||||
@@ -129,19 +126,43 @@ public class FilterSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.FilterTestCases },
|
ChannelIds = [ChannelIds.FilterTestCases],
|
||||||
|
ExportFormat = ExportFormat.Json,
|
||||||
|
OutputPath = file.Path,
|
||||||
|
MessageFilter = MessageFilter.Parse("has:invite")
|
||||||
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
|
.GetProperty("messages")
|
||||||
|
.EnumerateArray()
|
||||||
|
.Select(j => j.GetProperty("content").GetString())
|
||||||
|
.Should()
|
||||||
|
.AllSatisfy(c => c.Contains("This has invite", StringComparison.Ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task I_can_filter_the_export_to_only_include_messages_that_contain_the_specified_mention()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var file = TempFile.Create();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await new ExportChannelsCommand
|
||||||
|
{
|
||||||
|
Token = Secrets.DiscordToken,
|
||||||
|
ChannelIds = [ChannelIds.FilterTestCases],
|
||||||
ExportFormat = ExportFormat.Json,
|
ExportFormat = ExportFormat.Json,
|
||||||
OutputPath = file.Path,
|
OutputPath = file.Path,
|
||||||
MessageFilter = MessageFilter.Parse("mentions:Tyrrrz")
|
MessageFilter = MessageFilter.Parse("mentions:Tyrrrz")
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Json
|
Json.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.GetProperty("messages")
|
.GetProperty("messages")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(j => j.GetProperty("content").GetString())
|
.Select(j => j.GetProperty("content").GetString())
|
||||||
.Should()
|
.Should()
|
||||||
.ContainSingle("This has mention");
|
.AllSatisfy(c => c.Contains("This has mention", StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AngleSharp.Dom;
|
using AngleSharp.Dom;
|
||||||
using DiscordChatExporter.Cli.Tests.Infra;
|
using DiscordChatExporter.Cli.Tests.Infra;
|
||||||
@@ -11,7 +12,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class HtmlAttachmentSpecs
|
public class HtmlAttachmentSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_generic_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_generic_attachment()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -20,23 +21,17 @@ public class HtmlAttachmentSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().ContainAll(
|
message.Text().Should().ContainAll("Generic file attachment", "Test.txt", "11 bytes");
|
||||||
"Generic file attachment",
|
|
||||||
"Test.txt",
|
|
||||||
"11 bytes"
|
|
||||||
);
|
|
||||||
|
|
||||||
message
|
message
|
||||||
.QuerySelectorAll("a")
|
.QuerySelectorAll("a")
|
||||||
.Select(e => e.GetAttribute("href"))
|
.Select(e => e.GetAttribute("href"))
|
||||||
.Should()
|
.Should()
|
||||||
.Contain(
|
.Contain(u => u.Contains("Test.txt", StringComparison.Ordinal));
|
||||||
"https://cdn.discordapp.com/attachments/885587741654536192/885587844964417596/Test.txt"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_image_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_an_image_attachment()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -51,13 +46,11 @@ public class HtmlAttachmentSpecs
|
|||||||
.QuerySelectorAll("img")
|
.QuerySelectorAll("img")
|
||||||
.Select(e => e.GetAttribute("src"))
|
.Select(e => e.GetAttribute("src"))
|
||||||
.Should()
|
.Should()
|
||||||
.Contain(
|
.Contain(u => u.Contains("bird-thumbnail.png", StringComparison.Ordinal));
|
||||||
"https://cdn.discordapp.com/attachments/885587741654536192/885654862430359613/bird-thumbnail.png"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_video_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_video_attachment()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/333
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/333
|
||||||
|
|
||||||
@@ -71,13 +64,15 @@ public class HtmlAttachmentSpecs
|
|||||||
message.Text().Should().Contain("Video attachment");
|
message.Text().Should().Contain("Video attachment");
|
||||||
|
|
||||||
var videoUrl = message.QuerySelector("video source")?.GetAttribute("src");
|
var videoUrl = message.QuerySelector("video source")?.GetAttribute("src");
|
||||||
videoUrl.Should().Be(
|
videoUrl
|
||||||
"https://cdn.discordapp.com/attachments/885587741654536192/885655761512968233/file_example_MP4_640_3MG.mp4"
|
.Should()
|
||||||
);
|
.StartWith(
|
||||||
|
"https://cdn.discordapp.com/attachments/885587741654536192/885655761512968233/file_example_MP4_640_3MG.mp4"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_audio_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_an_audio_attachment()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/333
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/333
|
||||||
|
|
||||||
@@ -91,8 +86,10 @@ public class HtmlAttachmentSpecs
|
|||||||
message.Text().Should().Contain("Audio attachment");
|
message.Text().Should().Contain("Audio attachment");
|
||||||
|
|
||||||
var audioUrl = message.QuerySelector("audio source")?.GetAttribute("src");
|
var audioUrl = message.QuerySelector("audio source")?.GetAttribute("src");
|
||||||
audioUrl.Should().Be(
|
audioUrl
|
||||||
"https://cdn.discordapp.com/attachments/885587741654536192/885656175348187146/file_example_MP3_1MG.mp3"
|
.Should()
|
||||||
);
|
.StartWith(
|
||||||
|
"https://cdn.discordapp.com/attachments/885587741654536192/885656175348187146/file_example_MP3_1MG.mp3"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AngleSharp.Dom;
|
using AngleSharp.Dom;
|
||||||
using DiscordChatExporter.Cli.Tests.Infra;
|
using DiscordChatExporter.Cli.Tests.Infra;
|
||||||
using DiscordChatExporter.Core.Discord;
|
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -11,49 +10,38 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class HtmlContentSpecs
|
public class HtmlContentSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_are_exported_correctly()
|
public async Task I_can_export_a_channel_in_the_HTML_format()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var messages = await ExportWrapper.GetMessagesAsHtmlAsync(ChannelIds.DateRangeTestCases);
|
var messages = await ExportWrapper.GetMessagesAsHtmlAsync(ChannelIds.DateRangeTestCases);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
messages.Select(e => e.GetAttribute("data-message-id")).Should().Equal(
|
messages
|
||||||
"866674314627121232",
|
.Select(e => e.GetAttribute("data-message-id"))
|
||||||
"866710679758045195",
|
.Should()
|
||||||
"866732113319428096",
|
.Equal(
|
||||||
"868490009366396958",
|
"866674314627121232",
|
||||||
"868505966528835604",
|
"866710679758045195",
|
||||||
"868505969821364245",
|
"866732113319428096",
|
||||||
"868505973294268457",
|
"868490009366396958",
|
||||||
"885169254029213696"
|
"868505966528835604",
|
||||||
);
|
"868505969821364245",
|
||||||
|
"868505973294268457",
|
||||||
|
"885169254029213696"
|
||||||
|
);
|
||||||
|
|
||||||
messages.SelectMany(e => e.Text()).Should().ContainInOrder(
|
messages
|
||||||
"Hello world",
|
.SelectMany(e => e.Text())
|
||||||
"Goodbye world",
|
.Should()
|
||||||
"Foo bar",
|
.ContainInOrder(
|
||||||
"Hurdle Durdle",
|
"Hello world",
|
||||||
"One",
|
"Goodbye world",
|
||||||
"Two",
|
"Foo bar",
|
||||||
"Three",
|
"Hurdle Durdle",
|
||||||
"Yeet"
|
"One",
|
||||||
);
|
"Two",
|
||||||
|
"Three",
|
||||||
|
"Yeet"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
[Fact]
|
|
||||||
public async Task Messages_cross_posted_from_other_guilds_are_rendered_with_the_server_tag()
|
|
||||||
{
|
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/633
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.ReplyTestCases,
|
|
||||||
Snowflake.Parse("1072165330853576876")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("This is a test message from an announcement channel on another server");
|
|
||||||
message.Text().Should().Contain("SERVER");
|
|
||||||
message.QuerySelector(".chatlog__reply-link").Should().BeNull();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AngleSharp.Dom;
|
using AngleSharp.Dom;
|
||||||
using DiscordChatExporter.Cli.Tests.Infra;
|
using DiscordChatExporter.Cli.Tests.Infra;
|
||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
|
using DiscordChatExporter.Core.Utils.Extensions;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -11,7 +13,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class HtmlEmbedSpecs
|
public class HtmlEmbedSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_embed_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_rich_embed()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -20,19 +22,25 @@ public class HtmlEmbedSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().ContainAll(
|
message
|
||||||
"Embed author",
|
.Text()
|
||||||
"Embed title",
|
.Should()
|
||||||
"Embed description",
|
.ContainAll(
|
||||||
"Field 1", "Value 1",
|
"Embed author",
|
||||||
"Field 2", "Value 2",
|
"Embed title",
|
||||||
"Field 3", "Value 3",
|
"Embed description",
|
||||||
"Embed footer"
|
"Field 1",
|
||||||
);
|
"Value 1",
|
||||||
|
"Field 2",
|
||||||
|
"Value 2",
|
||||||
|
"Field 3",
|
||||||
|
"Value 3",
|
||||||
|
"Embed footer"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_image_link_is_rendered_with_an_image_embed()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_an_image_embed()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/537
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/537
|
||||||
|
|
||||||
@@ -46,13 +54,14 @@ public class HtmlEmbedSpecs
|
|||||||
message
|
message
|
||||||
.QuerySelectorAll("img")
|
.QuerySelectorAll("img")
|
||||||
.Select(e => e.GetAttribute("src"))
|
.Select(e => e.GetAttribute("src"))
|
||||||
.Where(s => s?.EndsWith("i.redd.it/f8w05ja8s4e61.png") ?? false)
|
.WhereNotNull()
|
||||||
|
.Where(s => s.Contains("f8w05ja8s4e61.png", StringComparison.Ordinal))
|
||||||
.Should()
|
.Should()
|
||||||
.ContainSingle();
|
.ContainSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_image_link_and_nothing_else_is_rendered_without_text_content()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_an_image_embed_and_the_text_is_hidden_if_it_only_contains_the_image_link()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/682
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/682
|
||||||
|
|
||||||
@@ -68,7 +77,31 @@ public class HtmlEmbedSpecs
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_GIFV_link_is_rendered_with_a_video_embed()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_video_embed()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.EmbedTestCases,
|
||||||
|
Snowflake.Parse("1083751036596002856")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
message
|
||||||
|
.QuerySelectorAll("source")
|
||||||
|
.Select(e => e.GetAttribute("src"))
|
||||||
|
.WhereNotNull()
|
||||||
|
.Where(s =>
|
||||||
|
s.Contains(
|
||||||
|
"i_am_currently_feeling_slight_displeasure_of_what_you_have_just_sent_lqrem.mp4",
|
||||||
|
StringComparison.Ordinal
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.Should()
|
||||||
|
.ContainSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_GIFV_embed()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -80,13 +113,14 @@ public class HtmlEmbedSpecs
|
|||||||
message
|
message
|
||||||
.QuerySelectorAll("source")
|
.QuerySelectorAll("source")
|
||||||
.Select(e => e.GetAttribute("src"))
|
.Select(e => e.GetAttribute("src"))
|
||||||
.Where(s => s?.EndsWith("media.tenor.com/DDAJeW6BQKkAAAPo/tooncasm-test-copy.mp4") ?? false)
|
.WhereNotNull()
|
||||||
|
.Where(s => s.Contains("tooncasm-test-copy.mp4", StringComparison.Ordinal))
|
||||||
.Should()
|
.Should()
|
||||||
.ContainSingle();
|
.ContainSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_GIFV_link_and_nothing_else_is_rendered_without_text_content()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_GIFV_embed_and_the_text_is_hidden_if_it_only_contains_the_video_link()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -100,7 +134,7 @@ public class HtmlEmbedSpecs
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_Spotify_track_link_is_rendered_with_a_track_embed()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_Spotify_track_embed()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/657
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/657
|
||||||
|
|
||||||
@@ -112,11 +146,31 @@ public class HtmlEmbedSpecs
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src");
|
var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src");
|
||||||
iframeUrl.Should().Be("https://open.spotify.com/embed/track/1LHZMWefF9502NPfArRfvP");
|
iframeUrl.Should().StartWith("https://open.spotify.com/embed/track/1LHZMWefF9502NPfArRfvP");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(Skip = "Twitch does not allow embeds from inside local HTML files")]
|
||||||
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_Twitch_clip_embed()
|
||||||
|
{
|
||||||
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1196
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.EmbedTestCases,
|
||||||
|
Snowflake.Parse("1207002986128216074")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src");
|
||||||
|
iframeUrl
|
||||||
|
.Should()
|
||||||
|
.StartWith(
|
||||||
|
"https://clips.twitch.tv/embed?clip=SpicyMildCiderThisIsSparta--PQhbllrvej_Ee7v"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_YouTube_video_link_is_rendered_with_a_video_embed()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_YouTube_video_embed()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/570
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/570
|
||||||
|
|
||||||
@@ -128,11 +182,11 @@ public class HtmlEmbedSpecs
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src");
|
var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src");
|
||||||
iframeUrl.Should().Be("https://www.youtube.com/embed/qOWW4OlgbvE");
|
iframeUrl.Should().StartWith("https://www.youtube.com/embed/qOWW4OlgbvE");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_Twitter_post_link_with_multiple_images_is_rendered_as_a_single_embed()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_Twitter_post_embed_that_includes_multiple_images()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/695
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/695
|
||||||
|
|
||||||
@@ -143,22 +197,52 @@ public class HtmlEmbedSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message
|
var imageUrls = message
|
||||||
.QuerySelectorAll("img")
|
.QuerySelectorAll("img")
|
||||||
.Select(e => e.GetAttribute("src"))
|
.Select(e => e.GetAttribute("src"))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
imageUrls
|
||||||
.Should()
|
.Should()
|
||||||
.ContainInOrder(
|
.Contain(u =>
|
||||||
"https://images-ext-1.discordapp.net/external/-n--xW3EHH_3jlrheVkMXHCM7T86b5Ty4-MzXCT4m1Q/https/pbs.twimg.com/media/FVYIzYPWAAAMBqZ.png",
|
u.EndsWith(
|
||||||
"https://images-ext-2.discordapp.net/external/z5nEmGeEldV-kswydGLhqUsFHbb5AWHtdvc9XT6N5rE/https/pbs.twimg.com/media/FVYJBWJWAAMNAx2.png",
|
"https/pbs.twimg.com/media/FVYIzYPWAAAMBqZ.png",
|
||||||
"https://images-ext-2.discordapp.net/external/gnip03SawMB6uZLagN5sRDpA_1Ap1CcEhMbJfK1z6WQ/https/pbs.twimg.com/media/FVYJHiRX0AANZcz.png",
|
StringComparison.Ordinal
|
||||||
"https://images-ext-2.discordapp.net/external/jl1v6cCbLaGmiwmKU-ZkXnF4cFsJ39f9A3-oEdqPdZs/https/pbs.twimg.com/media/FVYJNZNXwAAPnVG.png"
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
imageUrls
|
||||||
|
.Should()
|
||||||
|
.Contain(u =>
|
||||||
|
u.EndsWith(
|
||||||
|
"https/pbs.twimg.com/media/FVYJBWJWAAMNAx2.png",
|
||||||
|
StringComparison.Ordinal
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
imageUrls
|
||||||
|
.Should()
|
||||||
|
.Contain(u =>
|
||||||
|
u.EndsWith(
|
||||||
|
"https/pbs.twimg.com/media/FVYJHiRX0AANZcz.png",
|
||||||
|
StringComparison.Ordinal
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
imageUrls
|
||||||
|
.Should()
|
||||||
|
.Contain(u =>
|
||||||
|
u.EndsWith(
|
||||||
|
"https/pbs.twimg.com/media/FVYJNZNXwAAPnVG.png",
|
||||||
|
StringComparison.Ordinal
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
message.QuerySelectorAll(".chatlog__embed").Should().ContainSingle();
|
message.QuerySelectorAll(".chatlog__embed").Should().ContainSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_guild_invite_link_is_rendered_with_a_widget()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_guild_invite()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/649
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/649
|
||||||
|
|
||||||
@@ -169,6 +253,6 @@ public class HtmlEmbedSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().Contain("DiscordChatExporter TestServer");
|
message.Text().Should().Contain("DiscordChatExporter Test Server");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class HtmlGroupingSpecs
|
public class HtmlGroupingSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_are_grouped_correctly()
|
public async Task I_can_export_a_channel_and_the_messages_are_grouped_according_to_their_author_and_timestamps()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/152
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/152
|
||||||
|
|
||||||
@@ -26,14 +26,13 @@ public class HtmlGroupingSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.GroupingTestCases },
|
ChannelIds = [ChannelIds.GroupingTestCases],
|
||||||
ExportFormat = ExportFormat.HtmlDark,
|
ExportFormat = ExportFormat.HtmlDark,
|
||||||
OutputPath = file.Path
|
OutputPath = file.Path
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var messageGroups = Html
|
var messageGroups = Html.Parse(await File.ReadAllTextAsync(file.Path))
|
||||||
.Parse(await File.ReadAllTextAsync(file.Path))
|
|
||||||
.QuerySelectorAll(".chatlog__message-group");
|
.QuerySelectorAll(".chatlog__message-group");
|
||||||
|
|
||||||
messageGroups.Should().HaveCount(2);
|
messageGroups.Should().HaveCount(2);
|
||||||
@@ -59,12 +58,6 @@ public class HtmlGroupingSpecs
|
|||||||
.QuerySelectorAll(".chatlog__content")
|
.QuerySelectorAll(".chatlog__content")
|
||||||
.Select(e => e.Text())
|
.Select(e => e.Text())
|
||||||
.Should()
|
.Should()
|
||||||
.ContainInOrder(
|
.ContainInOrder("Eleventh", "Twelveth", "Thirteenth", "Fourteenth", "Fifteenth");
|
||||||
"Eleventh",
|
|
||||||
"Twelveth",
|
|
||||||
"Thirteenth",
|
|
||||||
"Fourteenth",
|
|
||||||
"Fifteenth"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AngleSharp.Dom;
|
using AngleSharp.Dom;
|
||||||
using DiscordChatExporter.Cli.Tests.Infra;
|
using DiscordChatExporter.Cli.Tests.Infra;
|
||||||
using DiscordChatExporter.Cli.Tests.Utils;
|
|
||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@@ -12,217 +10,130 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class HtmlMarkdownSpecs
|
public class HtmlMarkdownSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_timestamp_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074323136411078787")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message.Text().Should().Contain("Default timestamp: 2/12/2023 1:36 PM");
|
||||||
// Act
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.MarkdownTestCases,
|
|
||||||
Snowflake.Parse("1074323136411078787")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Default timestamp: 02/12/2023 3:36 PM");
|
|
||||||
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_short_time_timestamp_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_short_format()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074323205268967596")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message.Text().Should().Contain("Short time timestamp: 1:36 PM");
|
||||||
// Act
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.MarkdownTestCases,
|
|
||||||
Snowflake.Parse("1074323205268967596")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Short time timestamp: 3:36 PM");
|
|
||||||
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_long_time_timestamp_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_long_format()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074323235342139483")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message.Text().Should().Contain("Long time timestamp: 1:36:12 PM");
|
||||||
// Act
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.MarkdownTestCases,
|
|
||||||
Snowflake.Parse("1074323235342139483")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Long time timestamp: 3:36:12 PM");
|
|
||||||
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_short_date_timestamp_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_short_date_format()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074323326727634984")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message.Text().Should().Contain("Short date timestamp: 2/12/2023");
|
||||||
// Act
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.MarkdownTestCases,
|
|
||||||
Snowflake.Parse("1074323326727634984")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Short date timestamp: 02/12/2023");
|
|
||||||
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_long_date_timestamp_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_long_date_format()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074323350731640863")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message.Text().Should().Contain("Long date timestamp: Sunday, February 12, 2023");
|
||||||
// Act
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.MarkdownTestCases,
|
|
||||||
Snowflake.Parse("1074323350731640863")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Long date timestamp: February 12, 2023");
|
|
||||||
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_full_timestamp_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_full_format()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074323374379118593")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message.Text().Should().Contain("Full timestamp: Sunday, February 12, 2023 1:36 PM");
|
||||||
// Act
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.MarkdownTestCases,
|
|
||||||
Snowflake.Parse("1074323374379118593")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Full timestamp: February 12, 2023 3:36 PM");
|
|
||||||
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_full_long_timestamp_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_full_long_format()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074323409095376947")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message
|
||||||
// Act
|
.Text()
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
.Should()
|
||||||
ChannelIds.MarkdownTestCases,
|
.Contain("Full long timestamp: Sunday, February 12, 2023 1:36:12 PM");
|
||||||
Snowflake.Parse("1074323409095376947")
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Full long timestamp: Sunday, February 12, 2023 3:36 PM");
|
|
||||||
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_relative_timestamp_is_rendered_as_the_default_timestamp()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_relative_format()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074323436853285004")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message.Text().Should().Contain("Relative timestamp: 2/12/2023 1:36 PM");
|
||||||
// Act
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.MarkdownTestCases,
|
|
||||||
Snowflake.Parse("1074323436853285004")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Relative timestamp: 02/12/2023 3:36 PM");
|
|
||||||
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_invalid_timestamp_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_an_invalid_timestamp_marker()
|
||||||
{
|
{
|
||||||
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
// Act
|
||||||
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.MarkdownTestCases,
|
||||||
|
Snowflake.Parse("1074328534409019563")
|
||||||
|
);
|
||||||
|
|
||||||
try
|
// Assert
|
||||||
{
|
message.Text().Should().Contain("Invalid timestamp: Invalid date");
|
||||||
// Act
|
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
||||||
ChannelIds.MarkdownTestCases,
|
|
||||||
Snowflake.Parse("1074328534409019563")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
message.Text().Should().Contain("Invalid timestamp: Invalid date");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TimeZoneInfo.ClearCachedData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class HtmlMentionSpecs
|
public class HtmlMentionSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_user_mention_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_user_mention()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -20,11 +20,11 @@ public class HtmlMentionSpecs
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().Contain("User mention: @Tyrrrz");
|
message.Text().Should().Contain("User mention: @Tyrrrz");
|
||||||
message.InnerHtml.Should().Contain("Tyrrrz#5447");
|
message.InnerHtml.Should().Contain("tyrrrz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_text_channel_mention_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_text_channel_mention()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -37,7 +37,7 @@ public class HtmlMentionSpecs
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_voice_channel_mention_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_voice_channel_mention()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -50,7 +50,7 @@ public class HtmlMentionSpecs
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_role_mention_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_role_mention()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -61,4 +61,4 @@ public class HtmlMentionSpecs
|
|||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().Contain("Role mention: @Role 1");
|
message.Text().Should().Contain("Role mention: @Role 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class HtmlReplySpecs
|
public class HtmlReplySpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_reply_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_that_replies_to_another_message()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -24,7 +24,7 @@ public class HtmlReplySpecs
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_reply_to_a_deleted_message_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_that_replies_to_a_deleted_message()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/645
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/645
|
||||||
|
|
||||||
@@ -36,13 +36,15 @@ public class HtmlReplySpecs
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().Contain("reply to deleted");
|
message.Text().Should().Contain("reply to deleted");
|
||||||
message.QuerySelector(".chatlog__reply-link")?.Text().Should().Contain(
|
message
|
||||||
"Original message was deleted or could not be loaded."
|
.QuerySelector(".chatlog__reply-link")
|
||||||
);
|
?.Text()
|
||||||
|
.Should()
|
||||||
|
.Contain("Original message was deleted or could not be loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_reply_to_an_empty_message_with_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_that_replies_to_an_empty_message_with_an_attachment()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/634
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/634
|
||||||
|
|
||||||
@@ -54,11 +56,15 @@ public class HtmlReplySpecs
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().Contain("reply to attachment");
|
message.Text().Should().Contain("reply to attachment");
|
||||||
message.QuerySelector(".chatlog__reply-link")?.Text().Should().Contain("Click to see attachment");
|
message
|
||||||
|
.QuerySelector(".chatlog__reply-link")
|
||||||
|
?.Text()
|
||||||
|
.Should()
|
||||||
|
.Contain("Click to see attachment");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_reply_to_an_interaction_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_that_replies_to_an_interaction()
|
||||||
{
|
{
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/569
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/569
|
||||||
|
|
||||||
@@ -71,4 +77,24 @@ public class HtmlReplySpecs
|
|||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().Contain("used /poll");
|
message.Text().Should().Contain("used /poll");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
[Fact]
|
||||||
|
public async Task I_can_export_a_channel_that_contains_a_message_cross_posted_from_another_guild()
|
||||||
|
{
|
||||||
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/633
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
|
ChannelIds.ReplyTestCases,
|
||||||
|
Snowflake.Parse("1072165330853576876")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
message
|
||||||
|
.Text()
|
||||||
|
.Should()
|
||||||
|
.Contain("This is a test message from an announcement channel on another server");
|
||||||
|
message.Text().Should().Contain("SERVER");
|
||||||
|
message.QuerySelector(".chatlog__reply-link").Should().BeNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class HtmlStickerSpecs
|
public class HtmlStickerSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_PNG_based_sticker_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_PNG_sticker()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -19,11 +19,11 @@ public class HtmlStickerSpecs
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var stickerUrl = message.QuerySelector("[title='rock'] img")?.GetAttribute("src");
|
var stickerUrl = message.QuerySelector("[title='rock'] img")?.GetAttribute("src");
|
||||||
stickerUrl.Should().Be("https://discord.com/stickers/904215665597120572.png");
|
stickerUrl.Should().StartWith("https://cdn.discordapp.com/stickers/904215665597120572.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_Lottie_based_sticker_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_Lottie_sticker()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
||||||
@@ -32,7 +32,12 @@ public class HtmlStickerSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var stickerUrl = message.QuerySelector("[title='Yikes'] [data-source]")?.GetAttribute("data-source");
|
var stickerUrl = message
|
||||||
stickerUrl.Should().Be("https://discord.com/stickers/816087132447178774.json");
|
.QuerySelector("[title='Yikes'] [data-source]")
|
||||||
|
?.GetAttribute("data-source");
|
||||||
|
|
||||||
|
stickerUrl
|
||||||
|
.Should()
|
||||||
|
.StartWith("https://cdn.discordapp.com/stickers/816087132447178774.json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class JsonAttachmentSpecs
|
public class JsonAttachmentSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_generic_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_generic_attachment()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -23,15 +23,21 @@ public class JsonAttachmentSpecs
|
|||||||
|
|
||||||
var attachments = message.GetProperty("attachments").EnumerateArray().ToArray();
|
var attachments = message.GetProperty("attachments").EnumerateArray().ToArray();
|
||||||
attachments.Should().HaveCount(1);
|
attachments.Should().HaveCount(1);
|
||||||
attachments.Single().GetProperty("url").GetString().Should().Be(
|
|
||||||
"https://cdn.discordapp.com/attachments/885587741654536192/885587844964417596/Test.txt"
|
attachments[0]
|
||||||
);
|
.GetProperty("url")
|
||||||
attachments.Single().GetProperty("fileName").GetString().Should().Be("Test.txt");
|
.GetString()
|
||||||
attachments.Single().GetProperty("fileSizeBytes").GetInt64().Should().Be(11);
|
.Should()
|
||||||
|
.StartWith(
|
||||||
|
"https://cdn.discordapp.com/attachments/885587741654536192/885587844964417596/Test.txt"
|
||||||
|
);
|
||||||
|
|
||||||
|
attachments[0].GetProperty("fileName").GetString().Should().Be("Test.txt");
|
||||||
|
attachments[0].GetProperty("fileSizeBytes").GetInt64().Should().Be(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_image_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_an_image_attachment()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -44,15 +50,21 @@ public class JsonAttachmentSpecs
|
|||||||
|
|
||||||
var attachments = message.GetProperty("attachments").EnumerateArray().ToArray();
|
var attachments = message.GetProperty("attachments").EnumerateArray().ToArray();
|
||||||
attachments.Should().HaveCount(1);
|
attachments.Should().HaveCount(1);
|
||||||
attachments.Single().GetProperty("url").GetString().Should().Be(
|
|
||||||
"https://cdn.discordapp.com/attachments/885587741654536192/885654862430359613/bird-thumbnail.png"
|
attachments[0]
|
||||||
);
|
.GetProperty("url")
|
||||||
attachments.Single().GetProperty("fileName").GetString().Should().Be("bird-thumbnail.png");
|
.GetString()
|
||||||
attachments.Single().GetProperty("fileSizeBytes").GetInt64().Should().Be(466335);
|
.Should()
|
||||||
|
.StartWith(
|
||||||
|
"https://cdn.discordapp.com/attachments/885587741654536192/885654862430359613/bird-thumbnail.png"
|
||||||
|
);
|
||||||
|
|
||||||
|
attachments[0].GetProperty("fileName").GetString().Should().Be("bird-thumbnail.png");
|
||||||
|
attachments[0].GetProperty("fileSizeBytes").GetInt64().Should().Be(466335);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_video_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_video_attachment()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -65,15 +77,26 @@ public class JsonAttachmentSpecs
|
|||||||
|
|
||||||
var attachments = message.GetProperty("attachments").EnumerateArray().ToArray();
|
var attachments = message.GetProperty("attachments").EnumerateArray().ToArray();
|
||||||
attachments.Should().HaveCount(1);
|
attachments.Should().HaveCount(1);
|
||||||
attachments.Single().GetProperty("url").GetString().Should().Be(
|
|
||||||
"https://cdn.discordapp.com/attachments/885587741654536192/885655761512968233/file_example_MP4_640_3MG.mp4"
|
attachments[0]
|
||||||
);
|
.GetProperty("url")
|
||||||
attachments.Single().GetProperty("fileName").GetString().Should().Be("file_example_MP4_640_3MG.mp4");
|
.GetString()
|
||||||
attachments.Single().GetProperty("fileSizeBytes").GetInt64().Should().Be(3114374);
|
.Should()
|
||||||
|
.StartWith(
|
||||||
|
"https://cdn.discordapp.com/attachments/885587741654536192/885655761512968233/file_example_MP4_640_3MG.mp4"
|
||||||
|
);
|
||||||
|
|
||||||
|
attachments[0]
|
||||||
|
.GetProperty("fileName")
|
||||||
|
.GetString()
|
||||||
|
.Should()
|
||||||
|
.Be("file_example_MP4_640_3MG.mp4");
|
||||||
|
|
||||||
|
attachments[0].GetProperty("fileSizeBytes").GetInt64().Should().Be(3114374);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_audio_attachment_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_an_audio_attachment()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -86,10 +109,16 @@ public class JsonAttachmentSpecs
|
|||||||
|
|
||||||
var attachments = message.GetProperty("attachments").EnumerateArray().ToArray();
|
var attachments = message.GetProperty("attachments").EnumerateArray().ToArray();
|
||||||
attachments.Should().HaveCount(1);
|
attachments.Should().HaveCount(1);
|
||||||
attachments.Single().GetProperty("url").GetString().Should().Be(
|
|
||||||
"https://cdn.discordapp.com/attachments/885587741654536192/885656175348187146/file_example_MP3_1MG.mp3"
|
attachments[0]
|
||||||
);
|
.GetProperty("url")
|
||||||
attachments.Single().GetProperty("fileName").GetString().Should().Be("file_example_MP3_1MG.mp3");
|
.GetString()
|
||||||
attachments.Single().GetProperty("fileSizeBytes").GetInt64().Should().Be(1087849);
|
.Should()
|
||||||
|
.StartWith(
|
||||||
|
"https://cdn.discordapp.com/attachments/885587741654536192/885656175348187146/file_example_MP3_1MG.mp3"
|
||||||
|
);
|
||||||
|
|
||||||
|
attachments[0].GetProperty("fileName").GetString().Should().Be("file_example_MP3_1MG.mp3");
|
||||||
|
attachments[0].GetProperty("fileSizeBytes").GetInt64().Should().Be(1087849);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,32 +9,38 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class JsonContentSpecs
|
public class JsonContentSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_are_exported_correctly()
|
public async Task I_can_export_a_channel_in_the_JSON_format()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var messages = await ExportWrapper.GetMessagesAsJsonAsync(ChannelIds.DateRangeTestCases);
|
var messages = await ExportWrapper.GetMessagesAsJsonAsync(ChannelIds.DateRangeTestCases);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
messages.Select(j => j.GetProperty("id").GetString()).Should().Equal(
|
messages
|
||||||
"866674314627121232",
|
.Select(j => j.GetProperty("id").GetString())
|
||||||
"866710679758045195",
|
.Should()
|
||||||
"866732113319428096",
|
.Equal(
|
||||||
"868490009366396958",
|
"866674314627121232",
|
||||||
"868505966528835604",
|
"866710679758045195",
|
||||||
"868505969821364245",
|
"866732113319428096",
|
||||||
"868505973294268457",
|
"868490009366396958",
|
||||||
"885169254029213696"
|
"868505966528835604",
|
||||||
);
|
"868505969821364245",
|
||||||
|
"868505973294268457",
|
||||||
|
"885169254029213696"
|
||||||
|
);
|
||||||
|
|
||||||
messages.Select(j => j.GetProperty("content").GetString()).Should().Equal(
|
messages
|
||||||
"Hello world",
|
.Select(j => j.GetProperty("content").GetString())
|
||||||
"Goodbye world",
|
.Should()
|
||||||
"Foo bar",
|
.Equal(
|
||||||
"Hurdle Durdle",
|
"Hello world",
|
||||||
"One",
|
"Goodbye world",
|
||||||
"Two",
|
"Foo bar",
|
||||||
"Three",
|
"Hurdle Durdle",
|
||||||
"Yeet"
|
"One",
|
||||||
);
|
"Two",
|
||||||
|
"Three",
|
||||||
|
"Yeet"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class JsonEmbedSpecs
|
public class JsonEmbedSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_an_embed_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_rich_embed()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -52,4 +52,4 @@ public class JsonEmbedSpecs
|
|||||||
embedFields[2].GetProperty("value").GetString().Should().Be("Value 3");
|
embedFields[2].GetProperty("value").GetString().Should().Be("Value 3");
|
||||||
embedFields[2].GetProperty("isInline").GetBoolean().Should().BeTrue();
|
embedFields[2].GetProperty("isInline").GetBoolean().Should().BeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class JsonMentionSpecs
|
public class JsonMentionSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_user_mention_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_user_mention()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -30,7 +30,7 @@ public class JsonMentionSpecs
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_text_channel_mention_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_text_channel_mention()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -39,11 +39,15 @@ public class JsonMentionSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.GetProperty("content").GetString().Should().Be("Text channel mention: #mention-tests");
|
message
|
||||||
|
.GetProperty("content")
|
||||||
|
.GetString()
|
||||||
|
.Should()
|
||||||
|
.Be("Text channel mention: #mention-tests");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_voice_channel_mention_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_voice_channel_mention()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -52,11 +56,15 @@ public class JsonMentionSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.GetProperty("content").GetString().Should().Be("Voice channel mention: #general [voice]");
|
message
|
||||||
|
.GetProperty("content")
|
||||||
|
.GetString()
|
||||||
|
.Should()
|
||||||
|
.Be("Voice channel mention: #general [voice]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_role_mention_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_role_mention()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -67,4 +75,4 @@ public class JsonMentionSpecs
|
|||||||
// Assert
|
// Assert
|
||||||
message.GetProperty("content").GetString().Should().Be("Role mention: @Role 1");
|
message.GetProperty("content").GetString().Should().Be("Role mention: @Role 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class JsonStickerSpecs
|
public class JsonStickerSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_PNG_based_sticker_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_PNG_sticker()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -19,19 +19,20 @@ public class JsonStickerSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var sticker = message
|
var sticker = message.GetProperty("stickers").EnumerateArray().Single();
|
||||||
.GetProperty("stickers")
|
|
||||||
.EnumerateArray()
|
|
||||||
.Single();
|
|
||||||
|
|
||||||
sticker.GetProperty("id").GetString().Should().Be("904215665597120572");
|
sticker.GetProperty("id").GetString().Should().Be("904215665597120572");
|
||||||
sticker.GetProperty("name").GetString().Should().Be("rock");
|
sticker.GetProperty("name").GetString().Should().Be("rock");
|
||||||
sticker.GetProperty("format").GetString().Should().Be("PngAnimated");
|
sticker.GetProperty("format").GetString().Should().Be("Apng");
|
||||||
sticker.GetProperty("sourceUrl").GetString().Should().Be("https://discord.com/stickers/904215665597120572.png");
|
sticker
|
||||||
|
.GetProperty("sourceUrl")
|
||||||
|
.GetString()
|
||||||
|
.Should()
|
||||||
|
.StartWith("https://cdn.discordapp.com/stickers/904215665597120572.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Message_with_a_Lottie_based_sticker_is_rendered_correctly()
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_Lottie_sticker()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
var message = await ExportWrapper.GetMessageAsJsonAsync(
|
||||||
@@ -40,14 +41,15 @@ public class JsonStickerSpecs
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var sticker = message
|
var sticker = message.GetProperty("stickers").EnumerateArray().Single();
|
||||||
.GetProperty("stickers")
|
|
||||||
.EnumerateArray()
|
|
||||||
.Single();
|
|
||||||
|
|
||||||
sticker.GetProperty("id").GetString().Should().Be("816087132447178774");
|
sticker.GetProperty("id").GetString().Should().Be("816087132447178774");
|
||||||
sticker.GetProperty("name").GetString().Should().Be("Yikes");
|
sticker.GetProperty("name").GetString().Should().Be("Yikes");
|
||||||
sticker.GetProperty("format").GetString().Should().Be("Lottie");
|
sticker.GetProperty("format").GetString().Should().Be("Lottie");
|
||||||
sticker.GetProperty("sourceUrl").GetString().Should().Be("https://discord.com/stickers/816087132447178774.json");
|
sticker
|
||||||
|
.GetProperty("sourceUrl")
|
||||||
|
.GetString()
|
||||||
|
.Should()
|
||||||
|
.StartWith("https://cdn.discordapp.com/stickers/816087132447178774.json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class PartitioningSpecs
|
public class PartitioningSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_partitioned_by_count_are_split_into_a_corresponding_number_of_files()
|
public async Task I_can_export_a_channel_with_partitioning_based_on_message_count()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
using var dir = TempDir.Create();
|
using var dir = TempDir.Create();
|
||||||
@@ -24,20 +24,18 @@ public class PartitioningSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||||
ExportFormat = ExportFormat.HtmlDark,
|
ExportFormat = ExportFormat.HtmlDark,
|
||||||
OutputPath = filePath,
|
OutputPath = filePath,
|
||||||
PartitionLimit = PartitionLimit.Parse("3")
|
PartitionLimit = PartitionLimit.Parse("3")
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Directory.EnumerateFiles(dir.Path, "output*")
|
Directory.EnumerateFiles(dir.Path, "output*").Should().HaveCount(3);
|
||||||
.Should()
|
|
||||||
.HaveCount(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_partitioned_by_file_size_are_split_into_a_corresponding_number_of_files()
|
public async Task I_can_export_a_channel_with_partitioning_based_on_file_size()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
using var dir = TempDir.Create();
|
using var dir = TempDir.Create();
|
||||||
@@ -47,15 +45,13 @@ public class PartitioningSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.DateRangeTestCases },
|
ChannelIds = [ChannelIds.DateRangeTestCases],
|
||||||
ExportFormat = ExportFormat.HtmlDark,
|
ExportFormat = ExportFormat.HtmlDark,
|
||||||
OutputPath = filePath,
|
OutputPath = filePath,
|
||||||
PartitionLimit = PartitionLimit.Parse("1kb")
|
PartitionLimit = PartitionLimit.Parse("1kb")
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Directory.EnumerateFiles(dir.Path, "output*")
|
Directory.EnumerateFiles(dir.Path, "output*").Should().HaveCount(8);
|
||||||
.Should()
|
|
||||||
.HaveCount(8);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,22 +8,24 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class PlainTextContentSpecs
|
public class PlainTextContentSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_are_exported_correctly()
|
public async Task I_can_export_a_channel_in_the_TXT_format()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var document = await ExportWrapper.ExportAsPlainTextAsync(ChannelIds.DateRangeTestCases);
|
var document = await ExportWrapper.ExportAsPlainTextAsync(ChannelIds.DateRangeTestCases);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
document.Should().ContainAll(
|
document
|
||||||
"Tyrrrz#5447",
|
.Should()
|
||||||
"Hello world",
|
.ContainAll(
|
||||||
"Goodbye world",
|
"tyrrrz",
|
||||||
"Foo bar",
|
"Hello world",
|
||||||
"Hurdle Durdle",
|
"Goodbye world",
|
||||||
"One",
|
"Foo bar",
|
||||||
"Two",
|
"Hurdle Durdle",
|
||||||
"Three",
|
"One",
|
||||||
"Yeet"
|
"Two",
|
||||||
);
|
"Three",
|
||||||
|
"Yeet"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace DiscordChatExporter.Cli.Tests.Specs;
|
|||||||
public class SelfContainedSpecs
|
public class SelfContainedSpecs
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Messages_in_self_contained_export_only_reference_local_file_resources()
|
public async Task I_can_export_a_channel_and_download_all_referenced_assets()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
using var dir = TempDir.Create();
|
using var dir = TempDir.Create();
|
||||||
@@ -24,15 +24,14 @@ public class SelfContainedSpecs
|
|||||||
await new ExportChannelsCommand
|
await new ExportChannelsCommand
|
||||||
{
|
{
|
||||||
Token = Secrets.DiscordToken,
|
Token = Secrets.DiscordToken,
|
||||||
ChannelIds = new[] { ChannelIds.SelfContainedTestCases },
|
ChannelIds = [ChannelIds.SelfContainedTestCases],
|
||||||
ExportFormat = ExportFormat.HtmlDark,
|
ExportFormat = ExportFormat.HtmlDark,
|
||||||
OutputPath = filePath,
|
OutputPath = filePath,
|
||||||
ShouldDownloadAssets = true
|
ShouldDownloadAssets = true
|
||||||
}.ExecuteAsync(new FakeConsole());
|
}.ExecuteAsync(new FakeConsole());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Html
|
Html.Parse(await File.ReadAllTextAsync(filePath))
|
||||||
.Parse(await File.ReadAllTextAsync(filePath))
|
|
||||||
.QuerySelectorAll("body [src]")
|
.QuerySelectorAll("body [src]")
|
||||||
.Select(e => e.GetAttribute("src")!)
|
.Select(e => e.GetAttribute("src")!)
|
||||||
.Select(f => Path.GetFullPath(f, dir.Path))
|
.Select(f => Path.GetFullPath(f, dir.Path))
|
||||||
@@ -40,4 +39,4 @@ public class SelfContainedSpecs
|
|||||||
.Should()
|
.Should()
|
||||||
.BeTrue();
|
.BeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ internal static class Html
|
|||||||
private static readonly IHtmlParser Parser = new HtmlParser();
|
private static readonly IHtmlParser Parser = new HtmlParser();
|
||||||
|
|
||||||
public static IHtmlDocument Parse(string source) => Parser.ParseDocument(source);
|
public static IHtmlDocument Parse(string source) => Parser.ParseDocument(source);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,9 @@ using PathEx = System.IO.Path;
|
|||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Tests.Utils;
|
namespace DiscordChatExporter.Cli.Tests.Utils;
|
||||||
|
|
||||||
internal partial class TempDir : IDisposable
|
internal partial class TempDir(string path) : IDisposable
|
||||||
{
|
{
|
||||||
public string Path { get; }
|
public string Path { get; } = path;
|
||||||
|
|
||||||
public TempDir(string path) =>
|
|
||||||
Path = path;
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
@@ -18,9 +15,7 @@ internal partial class TempDir : IDisposable
|
|||||||
{
|
{
|
||||||
Directory.Delete(Path, true);
|
Directory.Delete(Path, true);
|
||||||
}
|
}
|
||||||
catch (DirectoryNotFoundException)
|
catch (DirectoryNotFoundException) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +24,8 @@ internal partial class TempDir
|
|||||||
public static TempDir Create()
|
public static TempDir Create()
|
||||||
{
|
{
|
||||||
var dirPath = PathEx.Combine(
|
var dirPath = PathEx.Combine(
|
||||||
PathEx.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Directory.GetCurrentDirectory(),
|
PathEx.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
||||||
|
?? Directory.GetCurrentDirectory(),
|
||||||
"Temp",
|
"Temp",
|
||||||
Guid.NewGuid().ToString()
|
Guid.NewGuid().ToString()
|
||||||
);
|
);
|
||||||
@@ -38,4 +34,4 @@ internal partial class TempDir
|
|||||||
|
|
||||||
return new TempDir(dirPath);
|
return new TempDir(dirPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,9 @@ using PathEx = System.IO.Path;
|
|||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Tests.Utils;
|
namespace DiscordChatExporter.Cli.Tests.Utils;
|
||||||
|
|
||||||
internal partial class TempFile : IDisposable
|
internal partial class TempFile(string path) : IDisposable
|
||||||
{
|
{
|
||||||
public string Path { get; }
|
public string Path { get; } = path;
|
||||||
|
|
||||||
public TempFile(string path) =>
|
|
||||||
Path = path;
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
@@ -18,9 +15,7 @@ internal partial class TempFile : IDisposable
|
|||||||
{
|
{
|
||||||
File.Delete(Path);
|
File.Delete(Path);
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
catch (FileNotFoundException) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,17 +24,15 @@ internal partial class TempFile
|
|||||||
public static TempFile Create()
|
public static TempFile Create()
|
||||||
{
|
{
|
||||||
var dirPath = PathEx.Combine(
|
var dirPath = PathEx.Combine(
|
||||||
PathEx.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Directory.GetCurrentDirectory(),
|
PathEx.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
||||||
|
?? Directory.GetCurrentDirectory(),
|
||||||
"Temp"
|
"Temp"
|
||||||
);
|
);
|
||||||
|
|
||||||
Directory.CreateDirectory(dirPath);
|
Directory.CreateDirectory(dirPath);
|
||||||
|
|
||||||
var filePath = PathEx.Combine(
|
var filePath = PathEx.Combine(dirPath, Guid.NewGuid() + ".tmp");
|
||||||
dirPath,
|
|
||||||
Guid.NewGuid() + ".tmp"
|
|
||||||
);
|
|
||||||
|
|
||||||
return new TempFile(filePath);
|
return new TempFile(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using ReflectionMagic;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Tests.Utils;
|
|
||||||
|
|
||||||
internal static class TimeZoneInfoEx
|
|
||||||
{
|
|
||||||
// https://stackoverflow.com/a/63700512/2205454
|
|
||||||
public static void SetLocal(TimeZoneInfo timeZone) =>
|
|
||||||
typeof(TimeZoneInfo).AsDynamicType().s_cachedData._localTimeZone = timeZone;
|
|
||||||
|
|
||||||
public static void SetLocal(TimeSpan offset) =>
|
|
||||||
SetLocal(TimeZoneInfo.CreateCustomTimeZone("test-tz", offset, "test-tz", "test-tz"));
|
|
||||||
}
|
|
||||||
@@ -1,44 +1,60 @@
|
|||||||
# -- Build
|
# -- Build
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
# Specify the platform here so that we pull the SDK image matching the host platform,
|
||||||
|
# instead of the target platform specified during build by the `--platform` option.
|
||||||
|
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
|
||||||
|
|
||||||
WORKDIR /build
|
# Expose the target architecture set by the `docker build --platform` option, so that
|
||||||
|
# we can build the assembly for the correct platform.
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
COPY favicon.ico ./
|
# Allow setting the assembly version from the build command
|
||||||
COPY NuGet.config ./
|
ARG VERSION=0.0.0
|
||||||
COPY Directory.Build.props ./
|
|
||||||
COPY DiscordChatExporter.Core ./DiscordChatExporter.Core
|
|
||||||
COPY DiscordChatExporter.Cli ./DiscordChatExporter.Cli
|
|
||||||
|
|
||||||
|
WORKDIR /tmp/app
|
||||||
|
|
||||||
|
COPY favicon.ico .
|
||||||
|
COPY NuGet.config .
|
||||||
|
COPY Directory.Build.props .
|
||||||
|
COPY DiscordChatExporter.Core DiscordChatExporter.Core
|
||||||
|
COPY DiscordChatExporter.Cli DiscordChatExporter.Cli
|
||||||
|
|
||||||
|
# Publish a self-contained assembly so we can use a slimmer runtime image
|
||||||
RUN dotnet publish DiscordChatExporter.Cli \
|
RUN dotnet publish DiscordChatExporter.Cli \
|
||||||
|
-p:Version=$VERSION \
|
||||||
|
-p:CSharpier_Bypass=true \
|
||||||
|
--configuration Release \
|
||||||
--self-contained \
|
--self-contained \
|
||||||
--use-current-runtime \
|
--use-current-runtime \
|
||||||
--configuration Release \
|
--arch $TARGETARCH \
|
||||||
--output ./publish
|
--output DiscordChatExporter.Cli/bin/publish/
|
||||||
|
|
||||||
# -- Run
|
# -- Run
|
||||||
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine
|
# Use `runtime-deps` instead of `runtime` because we have a self-contained assembly
|
||||||
|
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine AS run
|
||||||
|
|
||||||
# Alpine dotnet image doesn't include timezone data, which is needed
|
LABEL org.opencontainers.image.title="DiscordChatExporter.Cli"
|
||||||
# for certain date/time operations.
|
LABEL org.opencontainers.image.description="DiscordChatExporter is an application that can be used to export message history from any Discord channel to a file."
|
||||||
RUN apk add --no-cache tzdata
|
LABEL org.opencontainers.image.authors="tyrrrz.me"
|
||||||
|
LABEL org.opencontainers.image.source="https://github.com/Tyrrrz/DiscordChatExporter"
|
||||||
|
LABEL org.opencontainers.image.licenses="MIT"
|
||||||
|
|
||||||
# Create a non-root user to run the app, so that the output files
|
# Alpine image doesn't come with the ICU libraries pre-installed, so we need to install them manually.
|
||||||
# can be accessed by the host.
|
# We need the full ICU data because we allow the user to specify any locale for formatting purposes.
|
||||||
|
RUN apk add --no-cache icu-libs icu-data-full
|
||||||
|
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
||||||
|
ENV LC_ALL=en_US.UTF-8
|
||||||
|
ENV LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
# Use a non-root user to ensure that the files shared with the host are accessible by the host user
|
||||||
# https://github.com/Tyrrrz/DiscordChatExporter/issues/851
|
# https://github.com/Tyrrrz/DiscordChatExporter/issues/851
|
||||||
RUN adduser \
|
# https://github.com/Tyrrrz/DiscordChatExporter/issues/1174
|
||||||
--disabled-password \
|
RUN apk add --no-cache su-exec
|
||||||
--no-create-home \
|
RUN addgroup -S -g 1000 dce && adduser -S -H -G dce -u 1000 dce
|
||||||
dce
|
|
||||||
|
|
||||||
USER dce
|
# This directory is exposed to the user for mounting purposes, so it's important that it always
|
||||||
|
# stays the same for backwards compatibility.
|
||||||
COPY --from=build /build/publish /opt/dce
|
|
||||||
|
|
||||||
# Need to keep this as /out for backwards compatibility with documentation.
|
|
||||||
# A lot of people have this directory mounted in their scripts files, so
|
|
||||||
# changing it would break existing workflows.
|
|
||||||
WORKDIR /out
|
WORKDIR /out
|
||||||
|
|
||||||
# Add the app directory to PATH so that it's easier to debug using a shell
|
COPY --from=build /tmp/app/DiscordChatExporter.Cli/bin/publish /opt/app
|
||||||
ENV PATH="$PATH:/opt/dce"
|
COPY docker-entrypoint.sh /opt/app
|
||||||
ENTRYPOINT ["DiscordChatExporter.Cli"]
|
ENTRYPOINT ["/opt/app/docker-entrypoint.sh"]
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CliFx;
|
||||||
|
using CliFx.Attributes;
|
||||||
|
using CliFx.Infrastructure;
|
||||||
|
using DiscordChatExporter.Core.Discord;
|
||||||
|
using DiscordChatExporter.Core.Utils;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
|
||||||
|
public abstract class DiscordCommandBase : ICommand
|
||||||
|
{
|
||||||
|
[CommandOption(
|
||||||
|
"token",
|
||||||
|
't',
|
||||||
|
EnvironmentVariable = "DISCORD_TOKEN",
|
||||||
|
Description = "Authentication token."
|
||||||
|
)]
|
||||||
|
public required string Token { get; init; }
|
||||||
|
|
||||||
|
[Obsolete("This option doesn't do anything. Kept for backwards compatibility.")]
|
||||||
|
[CommandOption(
|
||||||
|
"bot",
|
||||||
|
'b',
|
||||||
|
EnvironmentVariable = "DISCORD_TOKEN_BOT",
|
||||||
|
Description = "This option doesn't do anything. Kept for backwards compatibility."
|
||||||
|
)]
|
||||||
|
public bool IsBotToken { get; init; } = false;
|
||||||
|
|
||||||
|
private DiscordClient? _discordClient;
|
||||||
|
protected DiscordClient Discord => _discordClient ??= new DiscordClient(Token);
|
||||||
|
|
||||||
|
public virtual ValueTask ExecuteAsync(IConsole console)
|
||||||
|
{
|
||||||
|
#pragma warning disable CS0618
|
||||||
|
// Warn if the bot option is used
|
||||||
|
if (IsBotToken)
|
||||||
|
{
|
||||||
|
using (console.WithForegroundColor(ConsoleColor.DarkYellow))
|
||||||
|
{
|
||||||
|
console.Error.WriteLine(
|
||||||
|
"Warning: The --bot option is deprecated and should not be used. "
|
||||||
|
+ "The token type is now inferred automatically. "
|
||||||
|
+ "Please update your workflows as this option may be completely removed in a future version."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore CS0618
|
||||||
|
|
||||||
|
// Note about interactivity for Docker
|
||||||
|
if (console.IsOutputRedirected && Docker.IsRunningInContainer)
|
||||||
|
{
|
||||||
|
console.Error.WriteLine(
|
||||||
|
"Note: Output streams are redirected, rich console interactions are disabled. "
|
||||||
|
+ "If you are running this command in Docker, consider allocating a pseudo-terminal for better user experience (docker run -it ...)."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Exceptions;
|
using CliFx.Exceptions;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
|
using DiscordChatExporter.Cli.Commands.Converters;
|
||||||
using DiscordChatExporter.Cli.Utils.Extensions;
|
using DiscordChatExporter.Cli.Utils.Extensions;
|
||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
using DiscordChatExporter.Core.Discord.Data;
|
using DiscordChatExporter.Core.Discord.Data;
|
||||||
@@ -14,24 +15,23 @@ using DiscordChatExporter.Core.Exceptions;
|
|||||||
using DiscordChatExporter.Core.Exporting;
|
using DiscordChatExporter.Core.Exporting;
|
||||||
using DiscordChatExporter.Core.Exporting.Filtering;
|
using DiscordChatExporter.Core.Exporting.Filtering;
|
||||||
using DiscordChatExporter.Core.Exporting.Partitioning;
|
using DiscordChatExporter.Core.Exporting.Partitioning;
|
||||||
using DiscordChatExporter.Core.Utils;
|
|
||||||
using DiscordChatExporter.Core.Utils.Extensions;
|
using DiscordChatExporter.Core.Utils.Extensions;
|
||||||
using Gress;
|
using Gress;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands.Base;
|
namespace DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
|
||||||
public abstract class ExportCommandBase : TokenCommandBase
|
public abstract class ExportCommandBase : DiscordCommandBase
|
||||||
{
|
{
|
||||||
private readonly string _outputPath = Directory.GetCurrentDirectory();
|
private readonly string _outputPath = Directory.GetCurrentDirectory();
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"output",
|
"output",
|
||||||
'o',
|
'o',
|
||||||
Description =
|
Description = "Output file or directory path. "
|
||||||
"Output file or directory path. " +
|
+ "If a directory is specified, file names will be generated automatically based on the channel names and export parameters. "
|
||||||
"If a directory is specified, file names will be generated automatically based on the channel names and other parameters. " +
|
+ "Directory paths must end with a slash to avoid ambiguity. "
|
||||||
"Directory path should end with a slash to avoid ambiguity. " +
|
+ "Supports template tokens, see the documentation for more info."
|
||||||
"Supports template tokens, see the documentation for more info."
|
|
||||||
)]
|
)]
|
||||||
public string OutputPath
|
public string OutputPath
|
||||||
{
|
{
|
||||||
@@ -41,11 +41,7 @@ public abstract class ExportCommandBase : TokenCommandBase
|
|||||||
init => _outputPath = Path.GetFullPath(value);
|
init => _outputPath = Path.GetFullPath(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption("format", 'f', Description = "Export format.")]
|
||||||
"format",
|
|
||||||
'f',
|
|
||||||
Description = "Export format."
|
|
||||||
)]
|
|
||||||
public ExportFormat ExportFormat { get; init; } = ExportFormat.HtmlDark;
|
public ExportFormat ExportFormat { get; init; } = ExportFormat.HtmlDark;
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
@@ -63,14 +59,15 @@ public abstract class ExportCommandBase : TokenCommandBase
|
|||||||
[CommandOption(
|
[CommandOption(
|
||||||
"partition",
|
"partition",
|
||||||
'p',
|
'p',
|
||||||
Description =
|
Description = "Split the output into partitions, each limited to the specified "
|
||||||
"Split output into partitions, each limited to this number of messages (e.g. '100') or file size (e.g. '10mb')."
|
+ "number of messages (e.g. '100') or file size (e.g. '10mb')."
|
||||||
)]
|
)]
|
||||||
public PartitionLimit PartitionLimit { get; init; } = PartitionLimit.Null;
|
public PartitionLimit PartitionLimit { get; init; } = PartitionLimit.Null;
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"filter",
|
"filter",
|
||||||
Description = "Only include messages that satisfy this filter (e.g. 'from:foo#1234' or 'has:image')."
|
Description = "Only include messages that satisfy this filter. "
|
||||||
|
+ "See the documentation for more info."
|
||||||
)]
|
)]
|
||||||
public MessageFilter MessageFilter { get; init; } = MessageFilter.Null;
|
public MessageFilter MessageFilter { get; init; } = MessageFilter.Null;
|
||||||
|
|
||||||
@@ -96,176 +93,221 @@ public abstract class ExportCommandBase : TokenCommandBase
|
|||||||
"reuse-media",
|
"reuse-media",
|
||||||
Description = "Reuse previously downloaded assets to avoid redundant requests."
|
Description = "Reuse previously downloaded assets to avoid redundant requests."
|
||||||
)]
|
)]
|
||||||
public bool ShouldReuseAssets { get; init; }
|
public bool ShouldReuseAssets { get; init; } = false;
|
||||||
|
|
||||||
|
private readonly string? _assetsDirPath;
|
||||||
|
|
||||||
|
[CommandOption(
|
||||||
|
"media-dir",
|
||||||
|
Description = "Download assets to this directory. "
|
||||||
|
+ "If not specified, the asset directory path will be derived from the output path."
|
||||||
|
)]
|
||||||
|
public string? AssetsDirPath
|
||||||
|
{
|
||||||
|
get => _assetsDirPath;
|
||||||
|
// Handle ~/ in paths on Unix systems
|
||||||
|
// https://github.com/Tyrrrz/DiscordChatExporter/pull/903
|
||||||
|
init => _assetsDirPath = value is not null ? Path.GetFullPath(value) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("This option doesn't do anything. Kept for backwards compatibility.")]
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"dateformat",
|
"dateformat",
|
||||||
Description = "Format used when writing dates."
|
Description = "This option doesn't do anything. Kept for backwards compatibility."
|
||||||
)]
|
)]
|
||||||
public string DateFormat { get; init; } = "MM/dd/yyyy h:mm tt";
|
public string DateFormat { get; init; } = "MM/dd/yyyy h:mm tt";
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"fuck-russia",
|
"locale",
|
||||||
Description = "Don't print the Support Ukraine message to the console."
|
Description = "Locale to use when formatting dates and numbers. "
|
||||||
|
+ "If not specified, the default system locale will be used."
|
||||||
)]
|
)]
|
||||||
public bool IsUkraineSupportMessageDisabled { get; init; }
|
public string? Locale { get; init; }
|
||||||
|
|
||||||
|
[CommandOption("utc", Description = "Normalize all timestamps to UTC+0.")]
|
||||||
|
public bool IsUtcNormalizationEnabled { get; init; } = false;
|
||||||
|
|
||||||
|
[CommandOption(
|
||||||
|
"fuck-russia",
|
||||||
|
EnvironmentVariable = "FUCK_RUSSIA",
|
||||||
|
Description = "Don't print the Support Ukraine message to the console.",
|
||||||
|
// Use a converter to accept '1' as 'true' to reuse the existing environment variable
|
||||||
|
Converter = typeof(TruthyBooleanBindingConverter)
|
||||||
|
)]
|
||||||
|
public bool IsUkraineSupportMessageDisabled { get; init; } = false;
|
||||||
|
|
||||||
private ChannelExporter? _channelExporter;
|
private ChannelExporter? _channelExporter;
|
||||||
protected ChannelExporter Exporter => _channelExporter ??= new ChannelExporter(Discord);
|
protected ChannelExporter Exporter => _channelExporter ??= new ChannelExporter(Discord);
|
||||||
|
|
||||||
protected async ValueTask ExecuteAsync(IConsole console, IReadOnlyList<Channel> channels)
|
protected async ValueTask ExportAsync(IConsole console, IReadOnlyList<Channel> channels)
|
||||||
{
|
{
|
||||||
// Reuse assets option should only be used when the download assets option is set.
|
// Asset reuse can only be enabled if the download assets option is set
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/425
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/425
|
||||||
if (ShouldReuseAssets && !ShouldDownloadAssets)
|
if (ShouldReuseAssets && !ShouldDownloadAssets)
|
||||||
{
|
{
|
||||||
throw new CommandException(
|
throw new CommandException("Option --reuse-media cannot be used without --media.");
|
||||||
"Option --reuse-media cannot be used without --media."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the user does not try to export all channels into a single file.
|
// Assets directory can only be specified if the download assets option is set
|
||||||
// Output path must either be a directory, or contain template tokens.
|
if (!string.IsNullOrWhiteSpace(AssetsDirPath) && !ShouldDownloadAssets)
|
||||||
|
{
|
||||||
|
throw new CommandException("Option --media-dir cannot be used without --media.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the user does not try to export multiple channels into one file.
|
||||||
|
// Output path must either be a directory or contain template tokens for this to work.
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/799
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/799
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/917
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/917
|
||||||
var isValidOutputPath =
|
var isValidOutputPath =
|
||||||
// Anything is valid when exporting a single channel
|
// Anything is valid when exporting a single channel
|
||||||
channels.Count <= 1 ||
|
channels.Count <= 1
|
||||||
// When using template tokens, assume the user knows what they're doing
|
// When using template tokens, assume the user knows what they're doing
|
||||||
OutputPath.Contains('%') ||
|
|| OutputPath.Contains('%')
|
||||||
// Otherwise, require an existing directory or an unambiguous directory path
|
// Otherwise, require an existing directory or an unambiguous directory path
|
||||||
Directory.Exists(OutputPath) || PathEx.IsDirectoryPath(OutputPath);
|
|| Directory.Exists(OutputPath)
|
||||||
|
|| Path.EndsInDirectorySeparator(OutputPath);
|
||||||
|
|
||||||
if (!isValidOutputPath)
|
if (!isValidOutputPath)
|
||||||
{
|
{
|
||||||
throw new CommandException(
|
throw new CommandException(
|
||||||
"Attempted to export multiple channels, but the output path is neither a directory nor a template. " +
|
"Attempted to export multiple channels, but the output path is neither a directory nor a template. "
|
||||||
"If the provided output path is meant to be treated as a directory, make sure it ends with a slash."
|
+ "If the provided output path is meant to be treated as a directory, make sure it ends with a slash. "
|
||||||
|
+ $"Provided output path: '{OutputPath}'."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cancellationToken = console.RegisterCancellationHandler();
|
|
||||||
var errors = new ConcurrentDictionary<Channel, string>();
|
|
||||||
|
|
||||||
// Export
|
// Export
|
||||||
|
var cancellationToken = console.RegisterCancellationHandler();
|
||||||
|
var errorsByChannel = new ConcurrentDictionary<Channel, string>();
|
||||||
|
|
||||||
await console.Output.WriteLineAsync($"Exporting {channels.Count} channel(s)...");
|
await console.Output.WriteLineAsync($"Exporting {channels.Count} channel(s)...");
|
||||||
await console.CreateProgressTicker().StartAsync(async progressContext =>
|
await console
|
||||||
{
|
.CreateProgressTicker()
|
||||||
await Parallel.ForEachAsync(
|
.HideCompleted(
|
||||||
channels,
|
// When exporting multiple channels in parallel, hide the completed tasks
|
||||||
new ParallelOptions
|
// because it gets hard to visually parse them as they complete out of order.
|
||||||
{
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1124
|
||||||
MaxDegreeOfParallelism = Math.Max(1, ParallelLimit),
|
ParallelLimit > 1
|
||||||
CancellationToken = cancellationToken
|
)
|
||||||
},
|
.StartAsync(async ctx =>
|
||||||
async (channel, innerCancellationToken) =>
|
{
|
||||||
{
|
await Parallel.ForEachAsync(
|
||||||
try
|
channels,
|
||||||
|
new ParallelOptions
|
||||||
{
|
{
|
||||||
await progressContext.StartTaskAsync(
|
MaxDegreeOfParallelism = Math.Max(1, ParallelLimit),
|
||||||
$"{channel.Category.Name} / {channel.Name}",
|
CancellationToken = cancellationToken
|
||||||
async progress =>
|
},
|
||||||
{
|
async (channel, innerCancellationToken) =>
|
||||||
var guild = await Discord.GetGuildAsync(channel.GuildId, innerCancellationToken);
|
|
||||||
|
|
||||||
var request = new ExportRequest(
|
|
||||||
guild,
|
|
||||||
channel,
|
|
||||||
OutputPath,
|
|
||||||
ExportFormat,
|
|
||||||
After,
|
|
||||||
Before,
|
|
||||||
PartitionLimit,
|
|
||||||
MessageFilter,
|
|
||||||
ShouldFormatMarkdown,
|
|
||||||
ShouldDownloadAssets,
|
|
||||||
ShouldReuseAssets,
|
|
||||||
DateFormat
|
|
||||||
);
|
|
||||||
|
|
||||||
await Exporter.ExportChannelAsync(
|
|
||||||
request,
|
|
||||||
progress.ToPercentageBased(),
|
|
||||||
innerCancellationToken
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
catch (DiscordChatExporterException ex) when (!ex.IsFatal)
|
|
||||||
{
|
{
|
||||||
errors[channel] = ex.Message;
|
try
|
||||||
}
|
{
|
||||||
}
|
await ctx.StartTaskAsync(
|
||||||
);
|
Markup.Escape(channel.GetHierarchicalName()),
|
||||||
});
|
async progress =>
|
||||||
|
{
|
||||||
|
var guild = await Discord.GetGuildAsync(
|
||||||
|
channel.GuildId,
|
||||||
|
innerCancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
// Print result
|
var request = new ExportRequest(
|
||||||
|
guild,
|
||||||
|
channel,
|
||||||
|
OutputPath,
|
||||||
|
AssetsDirPath,
|
||||||
|
ExportFormat,
|
||||||
|
After,
|
||||||
|
Before,
|
||||||
|
PartitionLimit,
|
||||||
|
MessageFilter,
|
||||||
|
ShouldFormatMarkdown,
|
||||||
|
ShouldDownloadAssets,
|
||||||
|
ShouldReuseAssets,
|
||||||
|
Locale,
|
||||||
|
IsUtcNormalizationEnabled
|
||||||
|
);
|
||||||
|
|
||||||
|
await Exporter.ExportChannelAsync(
|
||||||
|
request,
|
||||||
|
progress.ToPercentageBased(),
|
||||||
|
innerCancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (DiscordChatExporterException ex) when (!ex.IsFatal)
|
||||||
|
{
|
||||||
|
errorsByChannel[channel] = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Print the result
|
||||||
using (console.WithForegroundColor(ConsoleColor.White))
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
{
|
{
|
||||||
await console.Output.WriteLineAsync(
|
await console.Output.WriteLineAsync(
|
||||||
$"Successfully exported {channels.Count - errors.Count} channel(s)."
|
$"Successfully exported {channels.Count - errorsByChannel.Count} channel(s)."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print errors
|
// Print errors
|
||||||
if (errors.Any())
|
if (errorsByChannel.Any())
|
||||||
{
|
{
|
||||||
await console.Output.WriteLineAsync();
|
await console.Output.WriteLineAsync();
|
||||||
|
|
||||||
using (console.WithForegroundColor(ConsoleColor.Red))
|
using (console.WithForegroundColor(ConsoleColor.Red))
|
||||||
{
|
{
|
||||||
await console.Output.WriteLineAsync(
|
await console.Error.WriteLineAsync(
|
||||||
$"Failed to export {errors.Count} channel(s):"
|
$"Failed to export {errorsByChannel.Count} the following channel(s):"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var (channel, error) in errors)
|
foreach (var (channel, error) in errorsByChannel)
|
||||||
{
|
{
|
||||||
await console.Output.WriteAsync($"{channel.Category.Name} / {channel.Name}: ");
|
await console.Error.WriteAsync($"{channel.GetHierarchicalName()}: ");
|
||||||
|
|
||||||
using (console.WithForegroundColor(ConsoleColor.Red))
|
using (console.WithForegroundColor(ConsoleColor.Red))
|
||||||
await console.Output.WriteLineAsync(error);
|
await console.Error.WriteLineAsync(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
await console.Output.WriteLineAsync();
|
await console.Error.WriteLineAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail the command only if ALL channels failed to export.
|
// Fail the command only if ALL channels failed to export.
|
||||||
// Having some of the channels fail to export is expected.
|
// If only some channels failed to export, it's okay.
|
||||||
if (errors.Count >= channels.Count)
|
if (errorsByChannel.Count >= channels.Count)
|
||||||
{
|
|
||||||
throw new CommandException("Export failed.");
|
throw new CommandException("Export failed.");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async ValueTask ExecuteAsync(IConsole console, IReadOnlyList<Snowflake> channelIds)
|
protected async ValueTask ExportAsync(IConsole console, IReadOnlyList<Snowflake> channelIds)
|
||||||
{
|
{
|
||||||
var cancellationToken = console.RegisterCancellationHandler();
|
var cancellationToken = console.RegisterCancellationHandler();
|
||||||
|
|
||||||
await console.Output.WriteLineAsync("Resolving channel(s)...");
|
await console.Output.WriteLineAsync("Resolving channel(s)...");
|
||||||
|
|
||||||
var channels = new List<Channel>();
|
var channels = new List<Channel>();
|
||||||
var guildChannelMap = new Dictionary<Snowflake, IReadOnlyList<Channel>>();
|
var channelsByGuild = new Dictionary<Snowflake, IReadOnlyList<Channel>>();
|
||||||
|
|
||||||
foreach (var channelId in channelIds)
|
foreach (var channelId in channelIds)
|
||||||
{
|
{
|
||||||
var channel = await Discord.GetChannelAsync(channelId, cancellationToken);
|
var channel = await Discord.GetChannelAsync(channelId, cancellationToken);
|
||||||
|
|
||||||
// Unwrap categories
|
// Unwrap categories
|
||||||
if (channel.Kind == ChannelKind.GuildCategory)
|
if (channel.IsCategory)
|
||||||
{
|
{
|
||||||
var guildChannels =
|
var guildChannels =
|
||||||
guildChannelMap.GetValueOrDefault(channel.GuildId) ??
|
channelsByGuild.GetValueOrDefault(channel.GuildId)
|
||||||
await Discord.GetGuildChannelsAsync(channel.GuildId, cancellationToken);
|
?? await Discord.GetGuildChannelsAsync(channel.GuildId, cancellationToken);
|
||||||
|
|
||||||
foreach (var guildChannel in guildChannels)
|
foreach (var guildChannel in guildChannels)
|
||||||
{
|
{
|
||||||
if (guildChannel.Category.Id == channel.Id)
|
if (guildChannel.Parent?.Id == channel.Id)
|
||||||
channels.Add(guildChannel);
|
channels.Add(guildChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the guild channels to avoid redundant work
|
// Cache the guild channels to avoid redundant work
|
||||||
guildChannelMap[channel.GuildId] = guildChannels;
|
channelsByGuild[channel.GuildId] = guildChannels;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -273,26 +315,44 @@ public abstract class ExportCommandBase : TokenCommandBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await ExecuteAsync(console, channels);
|
await ExportAsync(console, channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
// Support Ukraine callout
|
// Support Ukraine callout
|
||||||
if (!IsUkraineSupportMessageDisabled)
|
if (!IsUkraineSupportMessageDisabled)
|
||||||
{
|
{
|
||||||
console.Output.WriteLine("┌────────────────────────────────────────────────────────────────────┐");
|
console.Output.WriteLine(
|
||||||
console.Output.WriteLine("│ Thank you for supporting Ukraine <3 │");
|
"┌────────────────────────────────────────────────────────────────────┐"
|
||||||
console.Output.WriteLine("│ │");
|
);
|
||||||
console.Output.WriteLine("│ As Russia wages a genocidal war against my country, │");
|
console.Output.WriteLine(
|
||||||
console.Output.WriteLine("│ I'm grateful to everyone who continues to │");
|
"│ Thank you for supporting Ukraine <3 │"
|
||||||
console.Output.WriteLine("│ stand with Ukraine in our fight for freedom. │");
|
);
|
||||||
console.Output.WriteLine("│ │");
|
console.Output.WriteLine(
|
||||||
console.Output.WriteLine("│ Learn more: https://tyrrrz.me/ukraine │");
|
"│ │"
|
||||||
console.Output.WriteLine("└────────────────────────────────────────────────────────────────────┘");
|
);
|
||||||
|
console.Output.WriteLine(
|
||||||
|
"│ As Russia wages a genocidal war against my country, │"
|
||||||
|
);
|
||||||
|
console.Output.WriteLine(
|
||||||
|
"│ I'm grateful to everyone who continues to │"
|
||||||
|
);
|
||||||
|
console.Output.WriteLine(
|
||||||
|
"│ stand with Ukraine in our fight for freedom. │"
|
||||||
|
);
|
||||||
|
console.Output.WriteLine(
|
||||||
|
"│ │"
|
||||||
|
);
|
||||||
|
console.Output.WriteLine(
|
||||||
|
"│ Learn more: https://tyrrrz.me/ukraine │"
|
||||||
|
);
|
||||||
|
console.Output.WriteLine(
|
||||||
|
"└────────────────────────────────────────────────────────────────────┘"
|
||||||
|
);
|
||||||
console.Output.WriteLine("");
|
console.Output.WriteLine("");
|
||||||
}
|
}
|
||||||
|
|
||||||
return default;
|
await base.ExecuteAsync(console);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using CliFx;
|
|
||||||
using CliFx.Attributes;
|
|
||||||
using CliFx.Infrastructure;
|
|
||||||
using DiscordChatExporter.Core.Discord;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands.Base;
|
|
||||||
|
|
||||||
public abstract class TokenCommandBase : ICommand
|
|
||||||
{
|
|
||||||
[CommandOption(
|
|
||||||
"token",
|
|
||||||
't',
|
|
||||||
EnvironmentVariable = "DISCORD_TOKEN",
|
|
||||||
Description = "Authentication token."
|
|
||||||
)]
|
|
||||||
public required string Token { get; init; }
|
|
||||||
|
|
||||||
[Obsolete("This option doesn't do anything. Kept for backwards compatibility.")]
|
|
||||||
[CommandOption(
|
|
||||||
"bot",
|
|
||||||
'b',
|
|
||||||
EnvironmentVariable = "DISCORD_TOKEN_BOT",
|
|
||||||
Description = "This option doesn't do anything. Kept for backwards compatibility."
|
|
||||||
)]
|
|
||||||
public bool IsBotToken { get; init; }
|
|
||||||
|
|
||||||
private DiscordClient? _discordClient;
|
|
||||||
protected DiscordClient Discord => _discordClient ??= new DiscordClient(Token);
|
|
||||||
|
|
||||||
public abstract ValueTask ExecuteAsync(IConsole console);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using CliFx.Extensibility;
|
||||||
|
using DiscordChatExporter.Cli.Commands.Shared;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Cli.Commands.Converters;
|
||||||
|
|
||||||
|
internal class ThreadInclusionModeBindingConverter : BindingConverter<ThreadInclusionMode>
|
||||||
|
{
|
||||||
|
public override ThreadInclusionMode Convert(string? rawValue)
|
||||||
|
{
|
||||||
|
// Empty or unset value is treated as 'active' to match the previous behavior
|
||||||
|
if (string.IsNullOrWhiteSpace(rawValue))
|
||||||
|
return ThreadInclusionMode.Active;
|
||||||
|
|
||||||
|
// Boolean 'true' is treated as 'active', boolean 'false' is treated as 'none'
|
||||||
|
if (bool.TryParse(rawValue, out var boolValue))
|
||||||
|
return boolValue ? ThreadInclusionMode.Active : ThreadInclusionMode.None;
|
||||||
|
|
||||||
|
// Otherwise, fall back to regular enum parsing
|
||||||
|
return Enum.Parse<ThreadInclusionMode>(rawValue, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using CliFx.Extensibility;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Cli.Commands.Converters;
|
||||||
|
|
||||||
|
internal class TruthyBooleanBindingConverter : BindingConverter<bool>
|
||||||
|
{
|
||||||
|
public override bool Convert(string? rawValue)
|
||||||
|
{
|
||||||
|
// Empty or unset value is treated as 'true', to match the regular boolean behavior
|
||||||
|
if (string.IsNullOrWhiteSpace(rawValue))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Number '1' is treated as 'true', other numbers are treated as 'false'
|
||||||
|
if (int.TryParse(rawValue, CultureInfo.InvariantCulture, out var intValue))
|
||||||
|
return intValue == 1;
|
||||||
|
|
||||||
|
// Otherwise, fall back to regular boolean parsing
|
||||||
|
return bool.Parse(rawValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,45 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using DiscordChatExporter.Cli.Commands.Base;
|
using DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
using DiscordChatExporter.Cli.Commands.Converters;
|
||||||
|
using DiscordChatExporter.Cli.Commands.Shared;
|
||||||
|
using DiscordChatExporter.Cli.Utils.Extensions;
|
||||||
using DiscordChatExporter.Core.Discord.Data;
|
using DiscordChatExporter.Core.Discord.Data;
|
||||||
|
using DiscordChatExporter.Core.Discord.Dump;
|
||||||
|
using DiscordChatExporter.Core.Exceptions;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
||||||
[Command("exportall", Description = "Export all accessible channels.")]
|
[Command("exportall", Description = "Exports all accessible channels.")]
|
||||||
public class ExportAllCommand : ExportCommandBase
|
public class ExportAllCommand : ExportCommandBase
|
||||||
{
|
{
|
||||||
|
[CommandOption("include-dm", Description = "Include direct message channels.")]
|
||||||
|
public bool IncludeDirectChannels { get; init; } = true;
|
||||||
|
|
||||||
|
[CommandOption("include-guilds", Description = "Include server channels.")]
|
||||||
|
public bool IncludeGuildChannels { get; init; } = true;
|
||||||
|
|
||||||
|
[CommandOption("include-vc", Description = "Include voice channels.")]
|
||||||
|
public bool IncludeVoiceChannels { get; init; } = true;
|
||||||
|
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"include-dm",
|
"include-threads",
|
||||||
Description = "Include direct message channels."
|
Description = "Which types of threads should be included.",
|
||||||
|
Converter = typeof(ThreadInclusionModeBindingConverter)
|
||||||
)]
|
)]
|
||||||
public bool IncludeDirectMessages { get; init; } = true;
|
public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None;
|
||||||
|
|
||||||
|
[CommandOption(
|
||||||
|
"data-package",
|
||||||
|
Description = "Path to the personal data package (ZIP file) requested from Discord. "
|
||||||
|
+ "If provided, only channels referenced in the dump will be exported."
|
||||||
|
)]
|
||||||
|
public string? DataPackageFilePath { get; init; }
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
@@ -23,17 +48,162 @@ public class ExportAllCommand : ExportCommandBase
|
|||||||
var cancellationToken = console.RegisterCancellationHandler();
|
var cancellationToken = console.RegisterCancellationHandler();
|
||||||
var channels = new List<Channel>();
|
var channels = new List<Channel>();
|
||||||
|
|
||||||
await console.Output.WriteLineAsync("Fetching channels...");
|
// Pull from the API
|
||||||
await foreach (var guild in Discord.GetUserGuildsAsync(cancellationToken))
|
if (string.IsNullOrWhiteSpace(DataPackageFilePath))
|
||||||
{
|
{
|
||||||
// Skip DMs if instructed to
|
await foreach (var guild in Discord.GetUserGuildsAsync(cancellationToken))
|
||||||
if (!IncludeDirectMessages && guild.Id == Guild.DirectMessages.Id)
|
{
|
||||||
continue;
|
// Regular channels
|
||||||
|
await console.Output.WriteLineAsync(
|
||||||
|
$"Fetching channels for server '{guild.Name}'..."
|
||||||
|
);
|
||||||
|
|
||||||
await foreach (var channel in Discord.GetGuildChannelsAsync(guild.Id, cancellationToken))
|
var fetchedChannelsCount = 0;
|
||||||
channels.Add(channel);
|
await console
|
||||||
|
.CreateStatusTicker()
|
||||||
|
.StartAsync(
|
||||||
|
"...",
|
||||||
|
async ctx =>
|
||||||
|
{
|
||||||
|
await foreach (
|
||||||
|
var channel in Discord.GetGuildChannelsAsync(
|
||||||
|
guild.Id,
|
||||||
|
cancellationToken
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (channel.IsCategory)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!IncludeVoiceChannels && channel.IsVoice)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
channels.Add(channel);
|
||||||
|
|
||||||
|
ctx.Status(
|
||||||
|
Markup.Escape($"Fetched '{channel.GetHierarchicalName()}'.")
|
||||||
|
);
|
||||||
|
|
||||||
|
fetchedChannelsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await console.Output.WriteLineAsync($"Fetched {fetchedChannelsCount} channel(s).");
|
||||||
|
|
||||||
|
// Threads
|
||||||
|
if (ThreadInclusionMode != ThreadInclusionMode.None)
|
||||||
|
{
|
||||||
|
await console.Output.WriteLineAsync(
|
||||||
|
$"Fetching threads for server '{guild.Name}'..."
|
||||||
|
);
|
||||||
|
|
||||||
|
var fetchedThreadsCount = 0;
|
||||||
|
await console
|
||||||
|
.CreateStatusTicker()
|
||||||
|
.StartAsync(
|
||||||
|
"...",
|
||||||
|
async ctx =>
|
||||||
|
{
|
||||||
|
await foreach (
|
||||||
|
var thread in Discord.GetGuildThreadsAsync(
|
||||||
|
guild.Id,
|
||||||
|
ThreadInclusionMode == ThreadInclusionMode.All,
|
||||||
|
Before,
|
||||||
|
After,
|
||||||
|
cancellationToken
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
channels.Add(thread);
|
||||||
|
|
||||||
|
ctx.Status(
|
||||||
|
Markup.Escape($"Fetched '{thread.GetHierarchicalName()}'.")
|
||||||
|
);
|
||||||
|
|
||||||
|
fetchedThreadsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await console.Output.WriteLineAsync(
|
||||||
|
$"Fetched {fetchedThreadsCount} thread(s)."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Pull from the data package
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await console.Output.WriteLineAsync("Extracting channels...");
|
||||||
|
|
||||||
|
var dump = await DataDump.LoadAsync(DataPackageFilePath, cancellationToken);
|
||||||
|
var inaccessibleChannels = new List<DataDumpChannel>();
|
||||||
|
|
||||||
|
await console
|
||||||
|
.CreateStatusTicker()
|
||||||
|
.StartAsync(
|
||||||
|
"...",
|
||||||
|
async ctx =>
|
||||||
|
{
|
||||||
|
foreach (var dumpChannel in dump.Channels)
|
||||||
|
{
|
||||||
|
ctx.Status(
|
||||||
|
Markup.Escape(
|
||||||
|
$"Fetching '{dumpChannel.Name}' ({dumpChannel.Id})..."
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var channel = await Discord.GetChannelAsync(
|
||||||
|
dumpChannel.Id,
|
||||||
|
cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
channels.Add(channel);
|
||||||
|
}
|
||||||
|
catch (DiscordChatExporterException)
|
||||||
|
{
|
||||||
|
inaccessibleChannels.Add(dumpChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await console.Output.WriteLineAsync($"Fetched {channels} channel(s).");
|
||||||
|
|
||||||
|
// Print inaccessible channels
|
||||||
|
if (inaccessibleChannels.Any())
|
||||||
|
{
|
||||||
|
await console.Output.WriteLineAsync();
|
||||||
|
|
||||||
|
using (console.WithForegroundColor(ConsoleColor.Red))
|
||||||
|
{
|
||||||
|
await console.Error.WriteLineAsync(
|
||||||
|
"Failed to access the following channel(s):"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var dumpChannel in inaccessibleChannels)
|
||||||
|
await console.Error.WriteLineAsync($"{dumpChannel.Name} ({dumpChannel.Id})");
|
||||||
|
|
||||||
|
await console.Error.WriteLineAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await base.ExecuteAsync(console, channels);
|
// Filter out unwanted channels
|
||||||
|
if (!IncludeDirectChannels)
|
||||||
|
channels.RemoveAll(c => c.IsDirect);
|
||||||
|
if (!IncludeGuildChannels)
|
||||||
|
channels.RemoveAll(c => c.IsGuild);
|
||||||
|
if (!IncludeVoiceChannels)
|
||||||
|
channels.RemoveAll(c => c.IsVoice);
|
||||||
|
if (ThreadInclusionMode == ThreadInclusionMode.None)
|
||||||
|
channels.RemoveAll(c => c.IsThread);
|
||||||
|
if (ThreadInclusionMode != ThreadInclusionMode.All)
|
||||||
|
channels.RemoveAll(c => c is { IsThread: true, IsArchived: true });
|
||||||
|
|
||||||
|
await ExportAsync(console, channels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,20 +7,21 @@ using DiscordChatExporter.Core.Discord;
|
|||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
||||||
[Command("export", Description = "Export one or multiple channels.")]
|
[Command("export", Description = "Exports one or multiple channels.")]
|
||||||
public class ExportChannelsCommand : ExportCommandBase
|
public class ExportChannelsCommand : ExportCommandBase
|
||||||
{
|
{
|
||||||
// TODO: change this to plural (breaking change)
|
// TODO: change this to plural (breaking change)
|
||||||
[CommandOption(
|
[CommandOption(
|
||||||
"channel",
|
"channel",
|
||||||
'c',
|
'c',
|
||||||
Description = "Channel ID(s). If provided with a category ID, all channels in that category will be exported."
|
Description = "Channel ID(s). "
|
||||||
|
+ "If provided with category ID(s), all channels inside those categories will be exported."
|
||||||
)]
|
)]
|
||||||
public required IReadOnlyList<Snowflake> ChannelIds { get; init; }
|
public required IReadOnlyList<Snowflake> ChannelIds { get; init; }
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
await base.ExecuteAsync(console);
|
await base.ExecuteAsync(console);
|
||||||
await base.ExecuteAsync(console, ChannelIds);
|
await ExportAsync(console, ChannelIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Linq;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using DiscordChatExporter.Cli.Commands.Base;
|
using DiscordChatExporter.Cli.Commands.Base;
|
||||||
@@ -8,7 +7,7 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
|||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
||||||
[Command("exportdm", Description = "Export all direct message channels.")]
|
[Command("exportdm", Description = "Exports all direct message channels.")]
|
||||||
public class ExportDirectMessagesCommand : ExportCommandBase
|
public class ExportDirectMessagesCommand : ExportCommandBase
|
||||||
{
|
{
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
@@ -18,11 +17,11 @@ public class ExportDirectMessagesCommand : ExportCommandBase
|
|||||||
var cancellationToken = console.RegisterCancellationHandler();
|
var cancellationToken = console.RegisterCancellationHandler();
|
||||||
|
|
||||||
await console.Output.WriteLineAsync("Fetching channels...");
|
await console.Output.WriteLineAsync("Fetching channels...");
|
||||||
|
var channels = await Discord.GetGuildChannelsAsync(
|
||||||
|
Guild.DirectMessages.Id,
|
||||||
|
cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
var channels = (await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id, cancellationToken))
|
await ExportAsync(console, channels);
|
||||||
.Where(c => c.Kind != ChannelKind.GuildCategory)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
await base.ExecuteAsync(console, channels);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,105 @@
|
|||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using DiscordChatExporter.Cli.Commands.Base;
|
using DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
using DiscordChatExporter.Cli.Commands.Converters;
|
||||||
|
using DiscordChatExporter.Cli.Commands.Shared;
|
||||||
|
using DiscordChatExporter.Cli.Utils.Extensions;
|
||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
using DiscordChatExporter.Core.Discord.Data;
|
using DiscordChatExporter.Core.Discord.Data;
|
||||||
using DiscordChatExporter.Core.Utils.Extensions;
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
||||||
[Command("exportguild", Description = "Export all channels within specified guild.")]
|
[Command("exportguild", Description = "Exports all channels within the specified server.")]
|
||||||
public class ExportGuildCommand : ExportCommandBase
|
public class ExportGuildCommand : ExportCommandBase
|
||||||
{
|
{
|
||||||
[CommandOption(
|
[CommandOption("guild", 'g', Description = "Server ID.")]
|
||||||
"guild",
|
|
||||||
'g',
|
|
||||||
Description = "Guild ID."
|
|
||||||
)]
|
|
||||||
public required Snowflake GuildId { get; init; }
|
public required Snowflake GuildId { get; init; }
|
||||||
|
|
||||||
|
[CommandOption("include-vc", Description = "Include voice channels.")]
|
||||||
|
public bool IncludeVoiceChannels { get; init; } = true;
|
||||||
|
|
||||||
|
[CommandOption(
|
||||||
|
"include-threads",
|
||||||
|
Description = "Which types of threads should be included.",
|
||||||
|
Converter = typeof(ThreadInclusionModeBindingConverter)
|
||||||
|
)]
|
||||||
|
public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None;
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
await base.ExecuteAsync(console);
|
await base.ExecuteAsync(console);
|
||||||
|
|
||||||
var cancellationToken = console.RegisterCancellationHandler();
|
var cancellationToken = console.RegisterCancellationHandler();
|
||||||
|
var channels = new List<Channel>();
|
||||||
|
|
||||||
|
// Regular channels
|
||||||
await console.Output.WriteLineAsync("Fetching channels...");
|
await console.Output.WriteLineAsync("Fetching channels...");
|
||||||
|
|
||||||
var channels = (await Discord.GetGuildChannelsAsync(GuildId, cancellationToken))
|
var fetchedChannelsCount = 0;
|
||||||
.Where(c => c.Kind != ChannelKind.GuildCategory)
|
await console
|
||||||
.ToArray();
|
.CreateStatusTicker()
|
||||||
|
.StartAsync(
|
||||||
|
"...",
|
||||||
|
async ctx =>
|
||||||
|
{
|
||||||
|
await foreach (
|
||||||
|
var channel in Discord.GetGuildChannelsAsync(GuildId, cancellationToken)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (channel.IsCategory)
|
||||||
|
continue;
|
||||||
|
|
||||||
await base.ExecuteAsync(console, channels);
|
if (!IncludeVoiceChannels && channel.IsVoice)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
channels.Add(channel);
|
||||||
|
|
||||||
|
ctx.Status(Markup.Escape($"Fetched '{channel.GetHierarchicalName()}'."));
|
||||||
|
|
||||||
|
fetchedChannelsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await console.Output.WriteLineAsync($"Fetched {fetchedChannelsCount} channel(s).");
|
||||||
|
|
||||||
|
// Threads
|
||||||
|
if (ThreadInclusionMode != ThreadInclusionMode.None)
|
||||||
|
{
|
||||||
|
await console.Output.WriteLineAsync("Fetching threads...");
|
||||||
|
|
||||||
|
var fetchedThreadsCount = 0;
|
||||||
|
await console
|
||||||
|
.CreateStatusTicker()
|
||||||
|
.StartAsync(
|
||||||
|
"...",
|
||||||
|
async ctx =>
|
||||||
|
{
|
||||||
|
await foreach (
|
||||||
|
var thread in Discord.GetGuildThreadsAsync(
|
||||||
|
GuildId,
|
||||||
|
ThreadInclusionMode == ThreadInclusionMode.All,
|
||||||
|
Before,
|
||||||
|
After,
|
||||||
|
cancellationToken
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
channels.Add(thread);
|
||||||
|
|
||||||
|
ctx.Status(Markup.Escape($"Fetched '{thread.GetHierarchicalName()}'."));
|
||||||
|
|
||||||
|
fetchedThreadsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await console.Output.WriteLineAsync($"Fetched {fetchedThreadsCount} thread(s).");
|
||||||
|
}
|
||||||
|
|
||||||
|
await ExportAsync(console, channels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,46 +4,111 @@ using System.Threading.Tasks;
|
|||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using DiscordChatExporter.Cli.Commands.Base;
|
using DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
using DiscordChatExporter.Cli.Commands.Converters;
|
||||||
|
using DiscordChatExporter.Cli.Commands.Shared;
|
||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
using DiscordChatExporter.Core.Discord.Data;
|
|
||||||
using DiscordChatExporter.Core.Utils.Extensions;
|
using DiscordChatExporter.Core.Utils.Extensions;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
||||||
[Command("channels", Description = "Get the list of channels in a guild.")]
|
[Command("channels", Description = "Get the list of channels in a server.")]
|
||||||
public class GetChannelsCommand : TokenCommandBase
|
public class GetChannelsCommand : DiscordCommandBase
|
||||||
{
|
{
|
||||||
[CommandOption(
|
[CommandOption("guild", 'g', Description = "Server ID.")]
|
||||||
"guild",
|
|
||||||
'g',
|
|
||||||
Description = "Guild ID."
|
|
||||||
)]
|
|
||||||
public required Snowflake GuildId { get; init; }
|
public required Snowflake GuildId { get; init; }
|
||||||
|
|
||||||
|
[CommandOption("include-vc", Description = "Include voice channels.")]
|
||||||
|
public bool IncludeVoiceChannels { get; init; } = true;
|
||||||
|
|
||||||
|
[CommandOption(
|
||||||
|
"include-threads",
|
||||||
|
Description = "Which types of threads should be included.",
|
||||||
|
Converter = typeof(ThreadInclusionModeBindingConverter)
|
||||||
|
)]
|
||||||
|
public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None;
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
|
await base.ExecuteAsync(console);
|
||||||
|
|
||||||
var cancellationToken = console.RegisterCancellationHandler();
|
var cancellationToken = console.RegisterCancellationHandler();
|
||||||
|
|
||||||
var channels = (await Discord.GetGuildChannelsAsync(GuildId, cancellationToken))
|
var channels = (await Discord.GetGuildChannelsAsync(GuildId, cancellationToken))
|
||||||
.Where(c => c.Kind != ChannelKind.GuildCategory)
|
.Where(c => !c.IsCategory)
|
||||||
.OrderBy(c => c.Category.Position)
|
.Where(c => IncludeVoiceChannels || !c.IsVoice)
|
||||||
|
.OrderBy(c => c.Parent?.Position)
|
||||||
.ThenBy(c => c.Name)
|
.ThenBy(c => c.Name)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
var channelIdMaxLength = channels
|
||||||
|
.Select(c => c.Id.ToString().Length)
|
||||||
|
.OrderDescending()
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
var threads =
|
||||||
|
ThreadInclusionMode != ThreadInclusionMode.None
|
||||||
|
? (
|
||||||
|
await Discord.GetGuildThreadsAsync(
|
||||||
|
GuildId,
|
||||||
|
ThreadInclusionMode == ThreadInclusionMode.All,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
cancellationToken
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.OrderBy(c => c.Name)
|
||||||
|
.ToArray()
|
||||||
|
: [];
|
||||||
|
|
||||||
foreach (var channel in channels)
|
foreach (var channel in channels)
|
||||||
{
|
{
|
||||||
// Channel ID
|
// Channel ID
|
||||||
await console.Output.WriteAsync(
|
await console.Output.WriteAsync(
|
||||||
channel.Id.ToString().PadRight(18, ' ')
|
channel.Id.ToString().PadRight(channelIdMaxLength, ' ')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||||
await console.Output.WriteAsync(" | ");
|
await console.Output.WriteAsync(" | ");
|
||||||
|
|
||||||
// Channel category / name
|
// Channel name
|
||||||
using (console.WithForegroundColor(ConsoleColor.White))
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
await console.Output.WriteLineAsync($"{channel.Category.Name} / {channel.Name}");
|
await console.Output.WriteLineAsync(channel.GetHierarchicalName());
|
||||||
|
|
||||||
|
var channelThreads = threads.Where(t => t.Parent?.Id == channel.Id).ToArray();
|
||||||
|
var channelThreadIdMaxLength = channelThreads
|
||||||
|
.Select(t => t.Id.ToString().Length)
|
||||||
|
.OrderDescending()
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
foreach (var channelThread in channelThreads)
|
||||||
|
{
|
||||||
|
// Indent
|
||||||
|
await console.Output.WriteAsync(" * ");
|
||||||
|
|
||||||
|
// Thread ID
|
||||||
|
await console.Output.WriteAsync(
|
||||||
|
channelThread.Id.ToString().PadRight(channelThreadIdMaxLength, ' ')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Separator
|
||||||
|
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||||
|
await console.Output.WriteAsync(" | ");
|
||||||
|
|
||||||
|
// Thread name
|
||||||
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
|
await console.Output.WriteAsync($"Thread / {channelThread.Name}");
|
||||||
|
|
||||||
|
// Separator
|
||||||
|
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||||
|
await console.Output.WriteAsync(" | ");
|
||||||
|
|
||||||
|
// Thread status
|
||||||
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
|
await console.Output.WriteLineAsync(
|
||||||
|
channelThread.IsArchived ? "Archived" : "Active"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-8
@@ -9,33 +9,41 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
|||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
||||||
[Command("dm", Description = "Get the list of direct message channels.")]
|
[Command("dm", Description = "Gets the list of all direct message channels.")]
|
||||||
public class GetDirectMessageChannelsCommand : TokenCommandBase
|
public class GetDirectChannelsCommand : DiscordCommandBase
|
||||||
{
|
{
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
|
await base.ExecuteAsync(console);
|
||||||
|
|
||||||
var cancellationToken = console.RegisterCancellationHandler();
|
var cancellationToken = console.RegisterCancellationHandler();
|
||||||
|
|
||||||
var channels = (await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id, cancellationToken))
|
var channels = (
|
||||||
.Where(c => c.Kind != ChannelKind.GuildCategory)
|
await Discord.GetGuildChannelsAsync(Guild.DirectMessages.Id, cancellationToken)
|
||||||
|
)
|
||||||
.OrderByDescending(c => c.LastMessageId)
|
.OrderByDescending(c => c.LastMessageId)
|
||||||
.ThenBy(c => c.Name)
|
.ThenBy(c => c.Name)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
var channelIdMaxLength = channels
|
||||||
|
.Select(c => c.Id.ToString().Length)
|
||||||
|
.OrderDescending()
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
foreach (var channel in channels)
|
foreach (var channel in channels)
|
||||||
{
|
{
|
||||||
// Channel ID
|
// Channel ID
|
||||||
await console.Output.WriteAsync(
|
await console.Output.WriteAsync(
|
||||||
channel.Id.ToString().PadRight(18, ' ')
|
channel.Id.ToString().PadRight(channelIdMaxLength, ' ')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||||
await console.Output.WriteAsync(" | ");
|
await console.Output.WriteAsync(" | ");
|
||||||
|
|
||||||
// Channel category / name
|
// Channel name
|
||||||
using (console.WithForegroundColor(ConsoleColor.White))
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
await console.Output.WriteLineAsync($"{channel.Category.Name} / {channel.Name}");
|
await console.Output.WriteLineAsync(channel.GetHierarchicalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,24 +9,30 @@ using DiscordChatExporter.Core.Utils.Extensions;
|
|||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
||||||
[Command("guilds", Description = "Get the list of accessible guilds.")]
|
[Command("guilds", Description = "Gets the list of accessible servers.")]
|
||||||
public class GetGuildsCommand : TokenCommandBase
|
public class GetGuildsCommand : DiscordCommandBase
|
||||||
{
|
{
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
|
await base.ExecuteAsync(console);
|
||||||
|
|
||||||
var cancellationToken = console.RegisterCancellationHandler();
|
var cancellationToken = console.RegisterCancellationHandler();
|
||||||
|
|
||||||
var guilds = (await Discord.GetUserGuildsAsync(cancellationToken))
|
var guilds = (await Discord.GetUserGuildsAsync(cancellationToken))
|
||||||
// Show direct messages first
|
// Show direct messages first
|
||||||
.OrderByDescending(g => g.Id == Guild.DirectMessages.Id)
|
.OrderByDescending(g => g.Id == Guild.DirectMessages.Id)
|
||||||
.ThenBy(g => g.Name);
|
.ThenBy(g => g.Name)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
var guildIdMaxLength = guilds
|
||||||
|
.Select(g => g.Id.ToString().Length)
|
||||||
|
.OrderDescending()
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
foreach (var guild in guilds)
|
foreach (var guild in guilds)
|
||||||
{
|
{
|
||||||
// Guild ID
|
// Guild ID
|
||||||
await console.Output.WriteAsync(
|
await console.Output.WriteAsync(guild.Id.ToString().PadRight(guildIdMaxLength, ' '));
|
||||||
guild.Id.ToString().PadRight(18, ' ')
|
|
||||||
);
|
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||||
@@ -37,4 +43,4 @@ public class GetGuildsCommand : TokenCommandBase
|
|||||||
await console.Output.WriteLineAsync(guild.Name);
|
await console.Output.WriteLineAsync(guild.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,23 +6,25 @@ using CliFx.Infrastructure;
|
|||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands;
|
namespace DiscordChatExporter.Cli.Commands;
|
||||||
|
|
||||||
[Command("guide", Description = "Explains how to obtain token, guild or channel ID.")]
|
[Command("guide", Description = "Explains how to obtain the token, server or channel ID.")]
|
||||||
public class GuideCommand : ICommand
|
public class GuideCommand : ICommand
|
||||||
{
|
{
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
// User token
|
// User token
|
||||||
using (console.WithForegroundColor(ConsoleColor.White))
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
console.Output.WriteLine("To get user token:");
|
console.Output.WriteLine("To get the token for your personal account:");
|
||||||
|
|
||||||
console.Output.WriteLine(" * Automating user accounts is technically against TOS — USE AT YOUR OWN RISK!");
|
console.Output.WriteLine(
|
||||||
|
" * Automating user accounts is technically against TOS — USE AT YOUR OWN RISK!"
|
||||||
|
);
|
||||||
console.Output.WriteLine(" 1. Open Discord in your web browser and login");
|
console.Output.WriteLine(" 1. Open Discord in your web browser and login");
|
||||||
console.Output.WriteLine(" 2. Open any server or direct message channel");
|
console.Output.WriteLine(" 2. Open any server or direct message channel");
|
||||||
console.Output.WriteLine(" 3. Press Ctrl+Shift+I to show developer tools");
|
console.Output.WriteLine(" 3. Press Ctrl+Shift+I to show developer tools");
|
||||||
console.Output.WriteLine(" 4. Navigate to the Network tab");
|
console.Output.WriteLine(" 4. Navigate to the Network tab");
|
||||||
console.Output.WriteLine(" 5. Press Ctrl+R to reload");
|
console.Output.WriteLine(" 5. Press Ctrl+R to reload");
|
||||||
console.Output.WriteLine(" 6. Switch between random channels to trigger network requests");
|
console.Output.WriteLine(" 6. Switch between random channels to trigger network requests");
|
||||||
console.Output.WriteLine(" 7. Search for a request containing \"messages?limit=50\" or similar");
|
console.Output.WriteLine(" 7. Search for a request that starts with \"messages\"");
|
||||||
console.Output.WriteLine(" 8. Select the Headers tab on the right");
|
console.Output.WriteLine(" 8. Select the Headers tab on the right");
|
||||||
console.Output.WriteLine(" 9. Scroll down to the Request Headers section");
|
console.Output.WriteLine(" 9. Scroll down to the Request Headers section");
|
||||||
console.Output.WriteLine(" 10. Copy the value of the \"authorization\" header");
|
console.Output.WriteLine(" 10. Copy the value of the \"authorization\" header");
|
||||||
@@ -30,44 +32,45 @@ public class GuideCommand : ICommand
|
|||||||
|
|
||||||
// Bot token
|
// Bot token
|
||||||
using (console.WithForegroundColor(ConsoleColor.White))
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
console.Output.WriteLine("To get bot token:");
|
console.Output.WriteLine("To get the token for your bot:");
|
||||||
|
|
||||||
console.Output.WriteLine(" 1. Go to Discord developer portal");
|
console.Output.WriteLine(" 1. Go to Discord developer portal");
|
||||||
console.Output.WriteLine(" 2. Open your application's settings");
|
console.Output.WriteLine(" 2. Open your application's settings");
|
||||||
console.Output.WriteLine(" 3. Navigate to the Bot section on the left");
|
console.Output.WriteLine(" 3. Navigate to the Bot section on the left");
|
||||||
console.Output.WriteLine(" 4. Under Token click Copy");
|
console.Output.WriteLine(" 4. Under Token click Copy");
|
||||||
console.Output.WriteLine(" * Your bot needs to have Message Content Intent enabled to read messages");
|
console.Output.WriteLine(
|
||||||
|
" * Your bot needs to have the Message Content Intent enabled to read messages"
|
||||||
|
);
|
||||||
console.Output.WriteLine();
|
console.Output.WriteLine();
|
||||||
|
|
||||||
// Guild or channel ID
|
// Guild or channel ID
|
||||||
using (console.WithForegroundColor(ConsoleColor.White))
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
console.Output.WriteLine("To get guild ID or guild channel ID:");
|
console.Output.WriteLine("To get the ID of a server or a channel:");
|
||||||
|
|
||||||
console.Output.WriteLine(" 1. Open Discord");
|
console.Output.WriteLine(" 1. Open Discord");
|
||||||
console.Output.WriteLine(" 2. Open Settings");
|
console.Output.WriteLine(" 2. Open Settings");
|
||||||
console.Output.WriteLine(" 3. Go to Advanced section");
|
console.Output.WriteLine(" 3. Go to Advanced section");
|
||||||
console.Output.WriteLine(" 4. Enable Developer Mode");
|
console.Output.WriteLine(" 4. Enable Developer Mode");
|
||||||
console.Output.WriteLine(" 5. Right click on the desired guild or channel and click Copy ID");
|
console.Output.WriteLine(
|
||||||
console.Output.WriteLine();
|
" 5. Right-click on the desired server or channel and click Copy Server ID or Copy Channel ID"
|
||||||
|
);
|
||||||
// Direct message channel ID
|
|
||||||
using (console.WithForegroundColor(ConsoleColor.White))
|
|
||||||
console.Output.WriteLine("To get direct message channel ID:");
|
|
||||||
|
|
||||||
console.Output.WriteLine(" 1. Open Discord");
|
|
||||||
console.Output.WriteLine(" 2. Open the desired direct message channel");
|
|
||||||
console.Output.WriteLine(" 3. Press Ctrl+Shift+I to show developer tools");
|
|
||||||
console.Output.WriteLine(" 4. Navigate to the Console tab");
|
|
||||||
console.Output.WriteLine(" 5. Type \"window.location.href\" and press Enter");
|
|
||||||
console.Output.WriteLine(" 6. Copy the first long sequence of numbers inside the URL");
|
|
||||||
console.Output.WriteLine();
|
console.Output.WriteLine();
|
||||||
|
|
||||||
// Docs link
|
// Docs link
|
||||||
using (console.WithForegroundColor(ConsoleColor.White))
|
using (console.WithForegroundColor(ConsoleColor.White))
|
||||||
console.Output.WriteLine("If you have questions or issues, please refer to the documentation:");
|
{
|
||||||
|
console.Output.WriteLine(
|
||||||
|
"If you have questions or issues, please refer to the documentation:"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
using (console.WithForegroundColor(ConsoleColor.DarkCyan))
|
using (console.WithForegroundColor(ConsoleColor.DarkCyan))
|
||||||
console.Output.WriteLine("https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs");
|
{
|
||||||
|
console.Output.WriteLine(
|
||||||
|
"https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace DiscordChatExporter.Cli.Commands.Shared;
|
||||||
|
|
||||||
|
public enum ThreadInclusionMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Active,
|
||||||
|
All
|
||||||
|
}
|
||||||
@@ -4,13 +4,14 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<ApplicationIcon>..\favicon.ico</ApplicationIcon>
|
<ApplicationIcon>..\favicon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CliFx" Version="2.3.1" />
|
<PackageReference Include="CliFx" Version="2.3.5" />
|
||||||
<PackageReference Include="FuckRussia" Version="1.0.1" PrivateAssets="all" />
|
<PackageReference Include="CSharpier.MsBuild" Version="0.28.2" PrivateAssets="all" />
|
||||||
<PackageReference Include="Spectre.Console" Version="0.46.0" />
|
<PackageReference Include="Deorcify" Version="1.0.2" PrivateAssets="all" />
|
||||||
<PackageReference Include="Gress" Version="2.0.1" />
|
<PackageReference Include="DotnetRuntimeBootstrapper" Version="2.5.4" PrivateAssets="all" />
|
||||||
<PackageReference Include="DotnetRuntimeBootstrapper" Version="2.4.0" PrivateAssets="all" />
|
<PackageReference Include="Gress" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Spectre.Console" Version="0.49.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
using CliFx;
|
using CliFx;
|
||||||
|
|
||||||
return await new CliApplicationBuilder()
|
return await new CliApplicationBuilder().AddCommandsFromThisAssembly().Build().RunAsync(args);
|
||||||
.AddCommandsFromThisAssembly()
|
|
||||||
.Build()
|
|
||||||
.RunAsync(args);
|
|
||||||
|
|||||||
@@ -8,34 +8,44 @@ namespace DiscordChatExporter.Cli.Utils.Extensions;
|
|||||||
internal static class ConsoleExtensions
|
internal static class ConsoleExtensions
|
||||||
{
|
{
|
||||||
public static IAnsiConsole CreateAnsiConsole(this IConsole console) =>
|
public static IAnsiConsole CreateAnsiConsole(this IConsole console) =>
|
||||||
AnsiConsole.Create(new AnsiConsoleSettings
|
AnsiConsole.Create(
|
||||||
{
|
new AnsiConsoleSettings
|
||||||
Ansi = AnsiSupport.Detect,
|
{
|
||||||
ColorSystem = ColorSystemSupport.Detect,
|
Ansi = AnsiSupport.Detect,
|
||||||
Out = new AnsiConsoleOutput(console.Output)
|
ColorSystem = ColorSystemSupport.Detect,
|
||||||
});
|
Out = new AnsiConsoleOutput(console.Output)
|
||||||
|
}
|
||||||
public static Progress CreateProgressTicker(this IConsole console) => console
|
|
||||||
.CreateAnsiConsole()
|
|
||||||
.Progress()
|
|
||||||
.AutoClear(false)
|
|
||||||
.AutoRefresh(true)
|
|
||||||
.HideCompleted(false)
|
|
||||||
.Columns(
|
|
||||||
new TaskDescriptionColumn {Alignment = Justify.Left},
|
|
||||||
new ProgressBarColumn(),
|
|
||||||
new PercentageColumn()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static Status CreateStatusTicker(this IConsole console) =>
|
||||||
|
console.CreateAnsiConsole().Status().AutoRefresh(true);
|
||||||
|
|
||||||
|
public static Progress CreateProgressTicker(this IConsole console) =>
|
||||||
|
console
|
||||||
|
.CreateAnsiConsole()
|
||||||
|
.Progress()
|
||||||
|
.AutoClear(false)
|
||||||
|
.AutoRefresh(true)
|
||||||
|
.HideCompleted(false)
|
||||||
|
.Columns(
|
||||||
|
new TaskDescriptionColumn { Alignment = Justify.Left },
|
||||||
|
new ProgressBarColumn(),
|
||||||
|
new PercentageColumn()
|
||||||
|
);
|
||||||
|
|
||||||
public static async ValueTask StartTaskAsync(
|
public static async ValueTask StartTaskAsync(
|
||||||
this ProgressContext progressContext,
|
this ProgressContext context,
|
||||||
string description,
|
string description,
|
||||||
Func<ProgressTask, ValueTask> performOperationAsync)
|
Func<ProgressTask, ValueTask> performOperationAsync
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var progressTask = progressContext.AddTask(
|
// Description cannot be empty
|
||||||
// Don't recognize random square brackets as style tags
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1133
|
||||||
Markup.Escape(description),
|
var actualDescription = !string.IsNullOrWhiteSpace(description) ? description : "...";
|
||||||
new ProgressTaskSettings {MaxValue = 1}
|
|
||||||
|
var progressTask = context.AddTask(
|
||||||
|
actualDescription,
|
||||||
|
new ProgressTaskSettings { MaxValue = 1 }
|
||||||
);
|
);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -48,4 +58,4 @@ internal static class ConsoleExtensions
|
|||||||
progressTask.StopTask();
|
progressTask.StopTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using DiscordChatExporter.Core.Utils.Extensions;
|
||||||
|
using JsonExtensions.Reading;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Core.Discord.Data;
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/application#application-object
|
||||||
|
public partial record Application(Snowflake Id, string Name, ApplicationFlags Flags)
|
||||||
|
{
|
||||||
|
public bool IsMessageContentIntentEnabled =>
|
||||||
|
Flags.HasFlag(ApplicationFlags.GatewayMessageContent)
|
||||||
|
|| Flags.HasFlag(ApplicationFlags.GatewayMessageContentLimited);
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial record Application
|
||||||
|
{
|
||||||
|
public static Application Parse(JsonElement json)
|
||||||
|
{
|
||||||
|
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
||||||
|
var name = json.GetProperty("name").GetNonWhiteSpaceString();
|
||||||
|
|
||||||
|
var flags =
|
||||||
|
json.GetPropertyOrNull("flags")?.GetInt32OrNull()?.Pipe(x => (ApplicationFlags)x)
|
||||||
|
?? ApplicationFlags.None;
|
||||||
|
|
||||||
|
return new Application(id, name, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Core.Discord.Data;
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/application#application-object-application-flags
|
||||||
|
[Flags]
|
||||||
|
public enum ApplicationFlags
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
ApplicationAutoModerationRuleCreateBadge = 64,
|
||||||
|
GatewayPresence = 4096,
|
||||||
|
GatewayPresenceLimited = 8192,
|
||||||
|
GatewayGuildMembers = 16384,
|
||||||
|
GatewayGuildMembersLimited = 32768,
|
||||||
|
VerificationPendingGuildLimit = 65536,
|
||||||
|
Embedded = 131072,
|
||||||
|
GatewayMessageContent = 262144,
|
||||||
|
GatewayMessageContentLimited = 524288,
|
||||||
|
ApplicationCommandBadge = 8388608
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||||
using DiscordChatExporter.Core.Utils;
|
|
||||||
using DiscordChatExporter.Core.Utils.Extensions;
|
using DiscordChatExporter.Core.Utils.Extensions;
|
||||||
using JsonExtensions.Reading;
|
using JsonExtensions.Reading;
|
||||||
|
|
||||||
@@ -16,15 +15,31 @@ public partial record Attachment(
|
|||||||
string? Description,
|
string? Description,
|
||||||
int? Width,
|
int? Width,
|
||||||
int? Height,
|
int? Height,
|
||||||
FileSize FileSize) : IHasId
|
FileSize FileSize
|
||||||
|
) : IHasId
|
||||||
{
|
{
|
||||||
public string FileExtension => Path.GetExtension(FileName);
|
public string FileExtension => Path.GetExtension(FileName);
|
||||||
|
|
||||||
public bool IsImage => FileFormat.IsImage(FileExtension);
|
public bool IsImage =>
|
||||||
|
string.Equals(FileExtension, ".jpg", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".jpeg", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".png", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".gif", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".bmp", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".webp", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public bool IsVideo => FileFormat.IsVideo(FileExtension);
|
public bool IsVideo =>
|
||||||
|
string.Equals(FileExtension, ".gifv", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".mp4", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".webm", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".mov", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public bool IsAudio => FileFormat.IsAudio(FileExtension);
|
public bool IsAudio =>
|
||||||
|
string.Equals(FileExtension, ".mp3", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".wav", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".ogg", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".flac", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| string.Equals(FileExtension, ".m4a", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public bool IsSpoiler => FileName.StartsWith("SPOILER_", StringComparison.Ordinal);
|
public bool IsSpoiler => FileName.StartsWith("SPOILER_", StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
@@ -43,4 +58,4 @@ public partial record Attachment
|
|||||||
|
|
||||||
return new Attachment(id, url, fileName, description, width, height, fileSize);
|
return new Attachment(id, url, fileName, description, width, height, fileSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||||
@@ -12,84 +12,104 @@ public partial record Channel(
|
|||||||
Snowflake Id,
|
Snowflake Id,
|
||||||
ChannelKind Kind,
|
ChannelKind Kind,
|
||||||
Snowflake GuildId,
|
Snowflake GuildId,
|
||||||
ChannelCategory Category,
|
Channel? Parent,
|
||||||
string Name,
|
string Name,
|
||||||
int? Position,
|
int? Position,
|
||||||
string? IconUrl,
|
string? IconUrl,
|
||||||
string? Topic,
|
string? Topic,
|
||||||
Snowflake? LastMessageId) : IHasId
|
bool IsArchived,
|
||||||
|
Snowflake? LastMessageId
|
||||||
|
) : IHasId
|
||||||
{
|
{
|
||||||
|
public bool IsDirect => Kind is ChannelKind.DirectTextChat or ChannelKind.DirectGroupTextChat;
|
||||||
|
|
||||||
|
public bool IsGuild => !IsDirect;
|
||||||
|
|
||||||
|
public bool IsCategory => Kind == ChannelKind.GuildCategory;
|
||||||
|
|
||||||
public bool IsVoice => Kind is ChannelKind.GuildVoiceChat or ChannelKind.GuildStageVoice;
|
public bool IsVoice => Kind is ChannelKind.GuildVoiceChat or ChannelKind.GuildStageVoice;
|
||||||
|
|
||||||
|
public bool IsThread =>
|
||||||
|
Kind
|
||||||
|
is ChannelKind.GuildNewsThread
|
||||||
|
or ChannelKind.GuildPublicThread
|
||||||
|
or ChannelKind.GuildPrivateThread;
|
||||||
|
|
||||||
|
public bool IsEmpty => LastMessageId is null;
|
||||||
|
|
||||||
|
public IEnumerable<Channel> GetParents()
|
||||||
|
{
|
||||||
|
var current = Parent;
|
||||||
|
while (current is not null)
|
||||||
|
{
|
||||||
|
yield return current;
|
||||||
|
current = current.Parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Channel? TryGetRootParent() => GetParents().LastOrDefault();
|
||||||
|
|
||||||
|
public string GetHierarchicalName() =>
|
||||||
|
string.Join(" / ", GetParents().Reverse().Select(c => c.Name).Append(Name));
|
||||||
|
|
||||||
|
public bool MayHaveMessagesAfter(Snowflake messageId) => !IsEmpty && messageId < LastMessageId;
|
||||||
|
|
||||||
|
public bool MayHaveMessagesBefore(Snowflake messageId) => !IsEmpty && messageId > Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial record Channel
|
public partial record Channel
|
||||||
{
|
{
|
||||||
private static ChannelCategory GetFallbackCategory(ChannelKind channelKind) => new(
|
public static Channel Parse(JsonElement json, Channel? parent = null, int? positionHint = null)
|
||||||
Snowflake.Zero,
|
|
||||||
channelKind switch
|
|
||||||
{
|
|
||||||
ChannelKind.GuildTextChat => "Text",
|
|
||||||
ChannelKind.DirectTextChat => "Private",
|
|
||||||
ChannelKind.DirectGroupTextChat => "Group",
|
|
||||||
ChannelKind.GuildNews => "News",
|
|
||||||
_ => "Default"
|
|
||||||
},
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
private static string GetIconUrl(Snowflake id, string iconHash)
|
|
||||||
{
|
|
||||||
var extension = iconHash.StartsWith("a_", StringComparison.Ordinal)
|
|
||||||
? "gif"
|
|
||||||
: "png";
|
|
||||||
|
|
||||||
return $"https://cdn.discordapp.com/channel-icons/{id}/{iconHash}.{extension}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Channel Parse(JsonElement json, ChannelCategory? category = null, int? positionHint = null)
|
|
||||||
{
|
{
|
||||||
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
||||||
var kind = (ChannelKind)json.GetProperty("type").GetInt32();
|
var kind = json.GetProperty("type").GetInt32().Pipe(t => (ChannelKind)t);
|
||||||
var guildId = json.GetPropertyOrNull("guild_id")?.GetNonWhiteSpaceStringOrNull()?.Pipe(Snowflake.Parse);
|
|
||||||
|
var guildId =
|
||||||
|
json.GetPropertyOrNull("guild_id")
|
||||||
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
|
?.Pipe(Snowflake.Parse) ?? Guild.DirectMessages.Id;
|
||||||
|
|
||||||
var name =
|
var name =
|
||||||
// Guild channel
|
// Guild channel
|
||||||
json.GetPropertyOrNull("name")?.GetNonWhiteSpaceStringOrNull() ??
|
json.GetPropertyOrNull("name")?.GetNonWhiteSpaceStringOrNull()
|
||||||
|
|
||||||
// DM channel
|
// DM channel
|
||||||
json.GetPropertyOrNull("recipients")?
|
?? json.GetPropertyOrNull("recipients")
|
||||||
.EnumerateArrayOrNull()?
|
?.EnumerateArrayOrNull()
|
||||||
.Select(User.Parse)
|
?.Select(User.Parse)
|
||||||
.Select(u => u.Name)
|
.Select(u => u.DisplayName)
|
||||||
.Pipe(s => string.Join(", ", s)) ??
|
.Pipe(s => string.Join(", ", s))
|
||||||
|
|
||||||
// Fallback
|
// Fallback
|
||||||
id.ToString();
|
?? id.ToString();
|
||||||
|
|
||||||
var position =
|
var position = positionHint ?? json.GetPropertyOrNull("position")?.GetInt32OrNull();
|
||||||
positionHint ??
|
|
||||||
json.GetPropertyOrNull("position")?.GetInt32OrNull();
|
|
||||||
|
|
||||||
// Only available on group DMs
|
// Icons can only be set for group DM channels
|
||||||
var iconUrl = json.GetPropertyOrNull("icon")?.GetNonWhiteSpaceStringOrNull()?.Pipe(h => GetIconUrl(id, h));
|
var iconUrl = json.GetPropertyOrNull("icon")
|
||||||
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
|
?.Pipe(h => ImageCdn.GetChannelIconUrl(id, h));
|
||||||
|
|
||||||
var topic = json.GetPropertyOrNull("topic")?.GetStringOrNull();
|
var topic = json.GetPropertyOrNull("topic")?.GetStringOrNull();
|
||||||
|
|
||||||
var lastMessageId = json
|
var isArchived =
|
||||||
.GetPropertyOrNull("last_message_id")?
|
json.GetPropertyOrNull("thread_metadata")
|
||||||
.GetNonWhiteSpaceStringOrNull()?
|
?.GetPropertyOrNull("archived")
|
||||||
.Pipe(Snowflake.Parse);
|
?.GetBooleanOrNull() ?? false;
|
||||||
|
|
||||||
|
var lastMessageId = json.GetPropertyOrNull("last_message_id")
|
||||||
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
|
?.Pipe(Snowflake.Parse);
|
||||||
|
|
||||||
return new Channel(
|
return new Channel(
|
||||||
id,
|
id,
|
||||||
kind,
|
kind,
|
||||||
guildId ?? Guild.DirectMessages.Id,
|
guildId,
|
||||||
category ?? GetFallbackCategory(kind),
|
parent,
|
||||||
name,
|
name,
|
||||||
position,
|
position,
|
||||||
iconUrl,
|
iconUrl,
|
||||||
topic,
|
topic,
|
||||||
|
isArchived,
|
||||||
lastMessageId
|
lastMessageId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
using System.Text.Json;
|
|
||||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
|
||||||
using DiscordChatExporter.Core.Utils.Extensions;
|
|
||||||
using JsonExtensions.Reading;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Discord.Data;
|
|
||||||
|
|
||||||
public record ChannelCategory(Snowflake Id, string Name, int? Position) : IHasId
|
|
||||||
{
|
|
||||||
public static ChannelCategory Unknown { get; } = new(Snowflake.Zero, "<unknown category>", 0);
|
|
||||||
|
|
||||||
public static ChannelCategory Parse(JsonElement json, int? positionHint = null)
|
|
||||||
{
|
|
||||||
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
|
||||||
|
|
||||||
var name =
|
|
||||||
json.GetPropertyOrNull("name")?.GetNonWhiteSpaceStringOrNull() ??
|
|
||||||
id.ToString();
|
|
||||||
|
|
||||||
var position =
|
|
||||||
positionHint ??
|
|
||||||
json.GetPropertyOrNull("position")?.GetInt32OrNull();
|
|
||||||
|
|
||||||
return new ChannelCategory(id, name, position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
namespace DiscordChatExporter.Core.Discord.Data;
|
namespace DiscordChatExporter.Core.Discord.Data;
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/channel#channel-object-channel-types
|
// https://discord.com/developers/docs/resources/channel#channel-object-channel-types
|
||||||
// Order of enum fields needs to match the order in the docs.
|
|
||||||
public enum ChannelKind
|
public enum ChannelKind
|
||||||
{
|
{
|
||||||
GuildTextChat = 0,
|
GuildTextChat = 0,
|
||||||
@@ -16,4 +15,4 @@ public enum ChannelKind
|
|||||||
GuildStageVoice = 13,
|
GuildStageVoice = 13,
|
||||||
GuildDirectory = 14,
|
GuildDirectory = 14,
|
||||||
GuildForum = 15
|
GuildForum = 15
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Core.Discord.Data;
|
||||||
|
|
||||||
|
public record ChannelNode(Channel Channel, IReadOnlyList<ChannelNode> Children)
|
||||||
|
{
|
||||||
|
public static IReadOnlyList<ChannelNode> BuildTree(IReadOnlyList<Channel> channels)
|
||||||
|
{
|
||||||
|
IReadOnlyList<ChannelNode> GetChildren(Channel parent) =>
|
||||||
|
channels
|
||||||
|
.Where(c => c.Parent?.Id == parent.Id)
|
||||||
|
.Select(c => new ChannelNode(c, GetChildren(c)))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
return channels
|
||||||
|
.Where(c => c.Parent is null)
|
||||||
|
.Select(c => new ChannelNode(c, GetChildren(c)))
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,10 +41,13 @@ public readonly partial record struct FileSize(long TotalBytes)
|
|||||||
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public override string ToString() =>
|
public override string ToString() =>
|
||||||
string.Create(CultureInfo.InvariantCulture, $"{GetLargestWholeNumberValue():0.##} {GetLargestWholeNumberSymbol()}");
|
string.Create(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
$"{GetLargestWholeNumberValue():0.##} {GetLargestWholeNumberSymbol()}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial record struct FileSize
|
public partial record struct FileSize
|
||||||
{
|
{
|
||||||
public static FileSize FromBytes(long bytes) => new(bytes);
|
public static FileSize FromBytes(long bytes) => new(bytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IHasId
|
public interface IHasId
|
||||||
{
|
{
|
||||||
Snowflake Id { get; }
|
Snowflake Id { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Discord.Data.Common;
|
|
||||||
|
|
||||||
public class IdBasedEqualityComparer : IEqualityComparer<IHasId>
|
|
||||||
{
|
|
||||||
public static IdBasedEqualityComparer Instance { get; } = new();
|
|
||||||
|
|
||||||
public bool Equals(IHasId? x, IHasId? y) => x?.Id == y?.Id;
|
|
||||||
|
|
||||||
public int GetHashCode(IHasId obj) => obj.Id.GetHashCode();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Core.Discord.Data.Common;
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/reference#image-formatting
|
||||||
|
public static class ImageCdn
|
||||||
|
{
|
||||||
|
// Standard emoji are rendered through Twemoji
|
||||||
|
public static string GetStandardEmojiUrl(string emojiName)
|
||||||
|
{
|
||||||
|
var runes = emojiName.EnumerateRunes().ToArray();
|
||||||
|
|
||||||
|
// Variant selector rune is skipped in Twemoji IDs,
|
||||||
|
// except when the emoji also contains a zero-width joiner.
|
||||||
|
// VS = 0xfe0f; ZWJ = 0x200d.
|
||||||
|
var filteredRunes = runes.Any(r => r.Value == 0x200d)
|
||||||
|
? runes
|
||||||
|
: runes.Where(r => r.Value != 0xfe0f);
|
||||||
|
|
||||||
|
var twemojiId = string.Join(
|
||||||
|
"-",
|
||||||
|
filteredRunes.Select(r => r.Value.ToString("x", CultureInfo.InvariantCulture))
|
||||||
|
);
|
||||||
|
|
||||||
|
return $"https://cdn.jsdelivr.net/gh/twitter/twemoji@latest/assets/svg/{twemojiId}.svg";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetCustomEmojiUrl(Snowflake emojiId, bool isAnimated = false) =>
|
||||||
|
isAnimated
|
||||||
|
? $"https://cdn.discordapp.com/emojis/{emojiId}.gif"
|
||||||
|
: $"https://cdn.discordapp.com/emojis/{emojiId}.png";
|
||||||
|
|
||||||
|
public static string GetGuildIconUrl(Snowflake guildId, string iconHash, int size = 512) =>
|
||||||
|
iconHash.StartsWith("a_", StringComparison.Ordinal)
|
||||||
|
? $"https://cdn.discordapp.com/icons/{guildId}/{iconHash}.gif?size={size}"
|
||||||
|
: $"https://cdn.discordapp.com/icons/{guildId}/{iconHash}.png?size={size}";
|
||||||
|
|
||||||
|
public static string GetChannelIconUrl(Snowflake channelId, string iconHash, int size = 512) =>
|
||||||
|
iconHash.StartsWith("a_", StringComparison.Ordinal)
|
||||||
|
? $"https://cdn.discordapp.com/channel-icons/{channelId}/{iconHash}.gif?size={size}"
|
||||||
|
: $"https://cdn.discordapp.com/channel-icons/{channelId}/{iconHash}.png?size={size}";
|
||||||
|
|
||||||
|
public static string GetUserAvatarUrl(Snowflake userId, string avatarHash, int size = 512) =>
|
||||||
|
avatarHash.StartsWith("a_", StringComparison.Ordinal)
|
||||||
|
? $"https://cdn.discordapp.com/avatars/{userId}/{avatarHash}.gif?size={size}"
|
||||||
|
: $"https://cdn.discordapp.com/avatars/{userId}/{avatarHash}.png?size={size}";
|
||||||
|
|
||||||
|
public static string GetFallbackUserAvatarUrl(int index = 0) =>
|
||||||
|
$"https://cdn.discordapp.com/embed/avatars/{index}.png";
|
||||||
|
|
||||||
|
public static string GetMemberAvatarUrl(
|
||||||
|
Snowflake guildId,
|
||||||
|
Snowflake userId,
|
||||||
|
string avatarHash,
|
||||||
|
int size = 512
|
||||||
|
) =>
|
||||||
|
avatarHash.StartsWith("a_", StringComparison.Ordinal)
|
||||||
|
? $"https://cdn.discordapp.com/guilds/{guildId}/users/{userId}/avatars/{avatarHash}.gif?size={size}"
|
||||||
|
: $"https://cdn.discordapp.com/guilds/{guildId}/users/{userId}/avatars/{avatarHash}.png?size={size}";
|
||||||
|
|
||||||
|
public static string GetStickerUrl(Snowflake stickerId, string format = "png") =>
|
||||||
|
$"https://cdn.discordapp.com/stickers/{stickerId}.{format}";
|
||||||
|
}
|
||||||
@@ -21,7 +21,8 @@ public partial record Embed(
|
|||||||
EmbedImage? Thumbnail,
|
EmbedImage? Thumbnail,
|
||||||
IReadOnlyList<EmbedImage> Images,
|
IReadOnlyList<EmbedImage> Images,
|
||||||
EmbedVideo? Video,
|
EmbedVideo? Video,
|
||||||
EmbedFooter? Footer)
|
EmbedFooter? Footer
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Embeds can only have one image according to the API model,
|
// Embeds can only have one image according to the API model,
|
||||||
// but the client can render multiple images in some cases.
|
// but the client can render multiple images in some cases.
|
||||||
@@ -30,6 +31,9 @@ public partial record Embed(
|
|||||||
public SpotifyTrackEmbedProjection? TryGetSpotifyTrack() =>
|
public SpotifyTrackEmbedProjection? TryGetSpotifyTrack() =>
|
||||||
SpotifyTrackEmbedProjection.TryResolve(this);
|
SpotifyTrackEmbedProjection.TryResolve(this);
|
||||||
|
|
||||||
|
public TwitchClipEmbedProjection? TryGetTwitchClip() =>
|
||||||
|
TwitchClipEmbedProjection.TryResolve(this);
|
||||||
|
|
||||||
public YouTubeVideoEmbedProjection? TryGetYouTubeVideo() =>
|
public YouTubeVideoEmbedProjection? TryGetYouTubeVideo() =>
|
||||||
YouTubeVideoEmbedProjection.TryResolve(this);
|
YouTubeVideoEmbedProjection.TryResolve(this);
|
||||||
}
|
}
|
||||||
@@ -41,24 +45,25 @@ public partial record Embed
|
|||||||
var title = json.GetPropertyOrNull("title")?.GetStringOrNull();
|
var title = json.GetPropertyOrNull("title")?.GetStringOrNull();
|
||||||
|
|
||||||
var kind =
|
var kind =
|
||||||
json.GetPropertyOrNull("type")?.GetStringOrNull()?.ParseEnumOrNull<EmbedKind>() ??
|
json.GetPropertyOrNull("type")?.GetStringOrNull()?.ParseEnumOrNull<EmbedKind>()
|
||||||
EmbedKind.Rich;
|
?? EmbedKind.Rich;
|
||||||
|
|
||||||
var url = json.GetPropertyOrNull("url")?.GetNonWhiteSpaceStringOrNull();
|
var url = json.GetPropertyOrNull("url")?.GetNonWhiteSpaceStringOrNull();
|
||||||
var timestamp = json.GetPropertyOrNull("timestamp")?.GetDateTimeOffset();
|
var timestamp = json.GetPropertyOrNull("timestamp")?.GetDateTimeOffsetOrNull();
|
||||||
|
|
||||||
var color = json
|
var color = json.GetPropertyOrNull("color")
|
||||||
.GetPropertyOrNull("color")?
|
?.GetInt32OrNull()
|
||||||
.GetInt32OrNull()?
|
?.Pipe(System.Drawing.Color.FromArgb)
|
||||||
.Pipe(System.Drawing.Color.FromArgb)
|
|
||||||
.ResetAlpha();
|
.ResetAlpha();
|
||||||
|
|
||||||
var author = json.GetPropertyOrNull("author")?.Pipe(EmbedAuthor.Parse);
|
var author = json.GetPropertyOrNull("author")?.Pipe(EmbedAuthor.Parse);
|
||||||
var description = json.GetPropertyOrNull("description")?.GetStringOrNull();
|
var description = json.GetPropertyOrNull("description")?.GetStringOrNull();
|
||||||
|
|
||||||
var fields =
|
var fields =
|
||||||
json.GetPropertyOrNull("fields")?.EnumerateArrayOrNull()?.Select(EmbedField.Parse).ToArray() ??
|
json.GetPropertyOrNull("fields")
|
||||||
Array.Empty<EmbedField>();
|
?.EnumerateArrayOrNull()
|
||||||
|
?.Select(EmbedField.Parse)
|
||||||
|
.ToArray() ?? [];
|
||||||
|
|
||||||
var thumbnail = json.GetPropertyOrNull("thumbnail")?.Pipe(EmbedImage.Parse);
|
var thumbnail = json.GetPropertyOrNull("thumbnail")?.Pipe(EmbedImage.Parse);
|
||||||
|
|
||||||
@@ -70,8 +75,10 @@ public partial record Embed
|
|||||||
// with this by merging related embeds at the end of the message parsing process.
|
// with this by merging related embeds at the end of the message parsing process.
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/695
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/695
|
||||||
var images =
|
var images =
|
||||||
json.GetPropertyOrNull("image")?.Pipe(EmbedImage.Parse).Enumerate().ToArray() ??
|
json.GetPropertyOrNull("image")
|
||||||
Array.Empty<EmbedImage>();
|
?.Pipe(EmbedImage.Parse)
|
||||||
|
.ToSingletonEnumerable()
|
||||||
|
.ToArray() ?? [];
|
||||||
|
|
||||||
var video = json.GetPropertyOrNull("video")?.Pipe(EmbedVideo.Parse);
|
var video = json.GetPropertyOrNull("video")?.Pipe(EmbedVideo.Parse);
|
||||||
|
|
||||||
@@ -92,4 +99,4 @@ public partial record Embed
|
|||||||
footer
|
footer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,7 @@ using JsonExtensions.Reading;
|
|||||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure
|
// https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure
|
||||||
public record EmbedAuthor(
|
public record EmbedAuthor(string? Name, string? Url, string? IconUrl, string? IconProxyUrl)
|
||||||
string? Name,
|
|
||||||
string? Url,
|
|
||||||
string? IconUrl,
|
|
||||||
string? IconProxyUrl)
|
|
||||||
{
|
{
|
||||||
public static EmbedAuthor Parse(JsonElement json)
|
public static EmbedAuthor Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
@@ -19,4 +15,4 @@ public record EmbedAuthor(
|
|||||||
|
|
||||||
return new EmbedAuthor(name, url, iconUrl, iconProxyUrl);
|
return new EmbedAuthor(name, url, iconUrl, iconProxyUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ using JsonExtensions.Reading;
|
|||||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure
|
// https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure
|
||||||
public record EmbedField(
|
public record EmbedField(string Name, string Value, bool IsInline)
|
||||||
string Name,
|
|
||||||
string Value,
|
|
||||||
bool IsInline)
|
|
||||||
{
|
{
|
||||||
public static EmbedField Parse(JsonElement json)
|
public static EmbedField Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
@@ -17,4 +14,4 @@ public record EmbedField(
|
|||||||
|
|
||||||
return new EmbedField(name, value, isInline);
|
return new EmbedField(name, value, isInline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ using JsonExtensions.Reading;
|
|||||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure
|
// https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure
|
||||||
public record EmbedFooter(
|
public record EmbedFooter(string Text, string? IconUrl, string? IconProxyUrl)
|
||||||
string Text,
|
|
||||||
string? IconUrl,
|
|
||||||
string? IconProxyUrl)
|
|
||||||
{
|
{
|
||||||
public static EmbedFooter Parse(JsonElement json)
|
public static EmbedFooter Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
@@ -17,4 +14,4 @@ public record EmbedFooter(
|
|||||||
|
|
||||||
return new EmbedFooter(text, iconUrl, iconProxyUrl);
|
return new EmbedFooter(text, iconUrl, iconProxyUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,7 @@ using JsonExtensions.Reading;
|
|||||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure
|
// https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure
|
||||||
public record EmbedImage(
|
public record EmbedImage(string? Url, string? ProxyUrl, int? Width, int? Height)
|
||||||
string? Url,
|
|
||||||
string? ProxyUrl,
|
|
||||||
int? Width,
|
|
||||||
int? Height)
|
|
||||||
{
|
{
|
||||||
public static EmbedImage Parse(JsonElement json)
|
public static EmbedImage Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
@@ -19,4 +15,4 @@ public record EmbedImage(
|
|||||||
|
|
||||||
return new EmbedImage(url, proxyUrl, width, height);
|
return new EmbedImage(url, proxyUrl, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ public enum EmbedKind
|
|||||||
Video,
|
Video,
|
||||||
Gifv,
|
Gifv,
|
||||||
Link
|
Link
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
using JsonExtensions.Reading;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using JsonExtensions.Reading;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure
|
// https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure
|
||||||
public record EmbedVideo(
|
public record EmbedVideo(string? Url, string? ProxyUrl, int? Width, int? Height)
|
||||||
string? Url,
|
|
||||||
string? ProxyUrl,
|
|
||||||
int? Width,
|
|
||||||
int? Height)
|
|
||||||
{
|
{
|
||||||
public static EmbedVideo Parse(JsonElement json)
|
public static EmbedVideo Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
@@ -19,4 +15,4 @@ public record EmbedVideo(
|
|||||||
|
|
||||||
return new EmbedVideo(url, proxyUrl, width, height);
|
return new EmbedVideo(url, proxyUrl, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ public partial record SpotifyTrackEmbedProjection
|
|||||||
private static string? TryParseTrackId(string embedUrl)
|
private static string? TryParseTrackId(string embedUrl)
|
||||||
{
|
{
|
||||||
// https://open.spotify.com/track/1LHZMWefF9502NPfArRfvP?si=3efac6ce9be04f0a
|
// https://open.spotify.com/track/1LHZMWefF9502NPfArRfvP?si=3efac6ce9be04f0a
|
||||||
var trackId = Regex.Match(embedUrl, @"spotify\.com/track/(.*?)(?:\?|&|/|$)").Groups[1].Value;
|
var trackId = Regex
|
||||||
|
.Match(embedUrl, @"spotify\.com/track/(.*?)(?:\?|&|/|$)")
|
||||||
|
.Groups[1]
|
||||||
|
.Value;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(trackId))
|
if (!string.IsNullOrWhiteSpace(trackId))
|
||||||
return trackId;
|
return trackId;
|
||||||
|
|
||||||
@@ -33,4 +37,4 @@ public partial record SpotifyTrackEmbedProjection
|
|||||||
|
|
||||||
return new SpotifyTrackEmbedProjection(trackId);
|
return new SpotifyTrackEmbedProjection(trackId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||||
|
|
||||||
|
public partial record TwitchClipEmbedProjection(string ClipId)
|
||||||
|
{
|
||||||
|
public string Url => $"https://clips.twitch.tv/embed?clip={ClipId}&parent=localhost";
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial record TwitchClipEmbedProjection
|
||||||
|
{
|
||||||
|
private static string? TryParseClipId(string embedUrl)
|
||||||
|
{
|
||||||
|
// https://clips.twitch.tv/SpookyTenuousPidgeonPanicVis
|
||||||
|
{
|
||||||
|
var clipId = Regex
|
||||||
|
.Match(embedUrl, @"clips\.twitch\.tv/(.*?)(?:\?|&|/|$)")
|
||||||
|
.Groups[1]
|
||||||
|
.Value;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(clipId))
|
||||||
|
return clipId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://twitch.tv/clip/SpookyTenuousPidgeonPanicVis
|
||||||
|
{
|
||||||
|
var clipId = Regex
|
||||||
|
.Match(embedUrl, @"twitch\.tv/clip/(.*?)(?:\?|&|/|$)")
|
||||||
|
.Groups[1]
|
||||||
|
.Value;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(clipId))
|
||||||
|
return clipId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TwitchClipEmbedProjection? TryResolve(Embed embed)
|
||||||
|
{
|
||||||
|
if (embed.Kind != EmbedKind.Video)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(embed.Url))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var clipId = TryParseClipId(embed.Url);
|
||||||
|
if (string.IsNullOrWhiteSpace(clipId))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new TwitchClipEmbedProjection(clipId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Text.RegularExpressions;
|
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
|
||||||
|
|
||||||
public partial record YouTubeVideoEmbedProjection(string VideoId)
|
public partial record YouTubeVideoEmbedProjection(string VideoId)
|
||||||
{
|
{
|
||||||
@@ -9,37 +7,6 @@ public partial record YouTubeVideoEmbedProjection(string VideoId)
|
|||||||
|
|
||||||
public partial record YouTubeVideoEmbedProjection
|
public partial record YouTubeVideoEmbedProjection
|
||||||
{
|
{
|
||||||
// Adapted from YoutubeExplode
|
|
||||||
// https://github.com/Tyrrrz/YoutubeExplode/blob/bc700b631bd105d0be208a88116347034bdca88b/YoutubeExplode/Videos/VideoId.cs#L40-L62
|
|
||||||
private static string? TryParseVideoId(string embedUrl)
|
|
||||||
{
|
|
||||||
// Regular URL
|
|
||||||
// https://www.youtube.com/watch?v=yIVRs6YSbOM
|
|
||||||
var regularMatch = Regex.Match(embedUrl, @"youtube\..+?/watch.*?v=(.*?)(?:&|/|$)").Groups[1].Value;
|
|
||||||
if (!string.IsNullOrWhiteSpace(regularMatch))
|
|
||||||
return regularMatch;
|
|
||||||
|
|
||||||
// Short URL
|
|
||||||
// https://youtu.be/yIVRs6YSbOM
|
|
||||||
var shortMatch = Regex.Match(embedUrl, @"youtu\.be/(.*?)(?:\?|&|/|$)").Groups[1].Value;
|
|
||||||
if (!string.IsNullOrWhiteSpace(shortMatch))
|
|
||||||
return shortMatch;
|
|
||||||
|
|
||||||
// Embed URL
|
|
||||||
// https://www.youtube.com/embed/yIVRs6YSbOM
|
|
||||||
var embedMatch = Regex.Match(embedUrl, @"youtube\..+?/embed/(.*?)(?:\?|&|/|$)").Groups[1].Value;
|
|
||||||
if (!string.IsNullOrWhiteSpace(embedMatch))
|
|
||||||
return embedMatch;
|
|
||||||
|
|
||||||
// Shorts URL
|
|
||||||
// https://www.youtube.com/shorts/sKL1vjP0tIo
|
|
||||||
var shortsMatch = Regex.Match(embedUrl, @"youtube\..+?/shorts/(.*?)(?:\?|&|/|$)").Groups[1].Value;
|
|
||||||
if (!string.IsNullOrWhiteSpace(shortsMatch))
|
|
||||||
return shortsMatch;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static YouTubeVideoEmbedProjection? TryResolve(Embed embed)
|
public static YouTubeVideoEmbedProjection? TryResolve(Embed embed)
|
||||||
{
|
{
|
||||||
if (embed.Kind != EmbedKind.Video)
|
if (embed.Kind != EmbedKind.Video)
|
||||||
@@ -48,10 +15,10 @@ public partial record YouTubeVideoEmbedProjection
|
|||||||
if (string.IsNullOrWhiteSpace(embed.Url))
|
if (string.IsNullOrWhiteSpace(embed.Url))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var videoId = TryParseVideoId(embed.Url);
|
var videoId = YoutubeExplode.Videos.VideoId.TryParse(embed.Url);
|
||||||
if (string.IsNullOrWhiteSpace(videoId))
|
if (videoId is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new YouTubeVideoEmbedProjection(videoId);
|
return new YouTubeVideoEmbedProjection(videoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||||
using DiscordChatExporter.Core.Utils;
|
using DiscordChatExporter.Core.Utils;
|
||||||
using DiscordChatExporter.Core.Utils.Extensions;
|
using DiscordChatExporter.Core.Utils.Extensions;
|
||||||
using JsonExtensions.Reading;
|
using JsonExtensions.Reading;
|
||||||
@@ -14,66 +14,41 @@ public partial record Emoji(
|
|||||||
// Name of a custom emoji (e.g. LUL) or actual representation of a standard emoji (e.g. 🙂)
|
// Name of a custom emoji (e.g. LUL) or actual representation of a standard emoji (e.g. 🙂)
|
||||||
string Name,
|
string Name,
|
||||||
bool IsAnimated,
|
bool IsAnimated,
|
||||||
string ImageUrl)
|
string ImageUrl
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Name of a custom emoji (e.g. LUL) or name of a standard emoji (e.g. slight_smile)
|
// Name of a custom emoji (e.g. LUL) or name of a standard emoji (e.g. slight_smile)
|
||||||
public string Code => Id is not null
|
public string Code => Id is not null ? Name : EmojiIndex.TryGetCode(Name) ?? Name;
|
||||||
? Name
|
|
||||||
: EmojiIndex.TryGetCode(Name) ?? Name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial record Emoji
|
public partial record Emoji
|
||||||
{
|
{
|
||||||
private static string GetTwemojiId(string name)
|
|
||||||
{
|
|
||||||
var runes = name.GetRunes().ToArray();
|
|
||||||
|
|
||||||
// Variant selector rune is skipped in Twemoji names, except when the emoji also contains a zero-width joiner.
|
|
||||||
// VS = 0xfe0f; ZWJ = 0x200d.
|
|
||||||
var filteredRunes = runes.Any(r => r.Value == 0x200d)
|
|
||||||
? runes
|
|
||||||
: runes.Where(r => r.Value != 0xfe0f);
|
|
||||||
|
|
||||||
return string.Join(
|
|
||||||
"-",
|
|
||||||
filteredRunes.Select(r => r.Value.ToString("x"))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetImageUrl(Snowflake id, bool isAnimated) => isAnimated
|
|
||||||
? $"https://cdn.discordapp.com/emojis/{id}.gif"
|
|
||||||
: $"https://cdn.discordapp.com/emojis/{id}.png";
|
|
||||||
|
|
||||||
private static string GetImageUrl(string name) =>
|
|
||||||
$"https://cdn.jsdelivr.net/gh/twitter/twemoji@latest/assets/svg/{GetTwemojiId(name)}.svg";
|
|
||||||
|
|
||||||
public static string GetImageUrl(Snowflake? id, string? name, bool isAnimated)
|
public static string GetImageUrl(Snowflake? id, string? name, bool isAnimated)
|
||||||
{
|
{
|
||||||
// Custom emoji
|
// Custom emoji
|
||||||
if (id is not null)
|
if (id is not null)
|
||||||
return GetImageUrl(id.Value, isAnimated);
|
return ImageCdn.GetCustomEmojiUrl(id.Value, isAnimated);
|
||||||
|
|
||||||
// Standard emoji
|
// Standard emoji
|
||||||
if (!string.IsNullOrWhiteSpace(name))
|
if (!string.IsNullOrWhiteSpace(name))
|
||||||
return GetImageUrl(name);
|
return ImageCdn.GetStandardEmojiUrl(name);
|
||||||
|
|
||||||
// Either ID or name should be set
|
throw new InvalidOperationException("Either the emoji ID or name should be provided.");
|
||||||
throw new ApplicationException("Emoji has neither ID nor name set.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Emoji Parse(JsonElement json)
|
public static Emoji Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
var id = json.GetPropertyOrNull("id")?.GetNonWhiteSpaceStringOrNull()?.Pipe(Snowflake.Parse);
|
var id = json.GetPropertyOrNull("id")
|
||||||
var name = json.GetPropertyOrNull("name")?.GetNonWhiteSpaceStringOrNull();
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
|
?.Pipe(Snowflake.Parse);
|
||||||
|
|
||||||
|
// Names may be missing on custom emoji within reactions
|
||||||
|
var name =
|
||||||
|
json.GetPropertyOrNull("name")?.GetNonWhiteSpaceStringOrNull() ?? "Unknown Emoji";
|
||||||
|
|
||||||
var isAnimated = json.GetPropertyOrNull("animated")?.GetBooleanOrNull() ?? false;
|
var isAnimated = json.GetPropertyOrNull("animated")?.GetBooleanOrNull() ?? false;
|
||||||
var imageUrl = GetImageUrl(id, name, isAnimated);
|
var imageUrl = GetImageUrl(id, name, isAnimated);
|
||||||
|
|
||||||
return new Emoji(
|
return new Emoji(id, name, isAnimated, imageUrl);
|
||||||
id,
|
|
||||||
// Name may be missing if it's an emoji inside a reaction
|
|
||||||
name ?? "<unknown emoji>",
|
|
||||||
isAnimated,
|
|
||||||
imageUrl
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Text.Json;
|
||||||
using System.Text.Json;
|
|
||||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||||
using DiscordChatExporter.Core.Utils.Extensions;
|
using DiscordChatExporter.Core.Utils.Extensions;
|
||||||
using JsonExtensions.Reading;
|
using JsonExtensions.Reading;
|
||||||
@@ -7,25 +6,16 @@ using JsonExtensions.Reading;
|
|||||||
namespace DiscordChatExporter.Core.Discord.Data;
|
namespace DiscordChatExporter.Core.Discord.Data;
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/guild#guild-object
|
// https://discord.com/developers/docs/resources/guild#guild-object
|
||||||
public record Guild(Snowflake Id, string Name, string IconUrl) : IHasId
|
public partial record Guild(Snowflake Id, string Name, string IconUrl) : IHasId
|
||||||
{
|
{
|
||||||
public static Guild DirectMessages { get; } = new(
|
public bool IsDirect => Id == DirectMessages.Id;
|
||||||
Snowflake.Zero,
|
}
|
||||||
"Direct Messages",
|
|
||||||
GetDefaultIconUrl()
|
|
||||||
);
|
|
||||||
|
|
||||||
private static string GetDefaultIconUrl() =>
|
public partial record Guild
|
||||||
"https://cdn.discordapp.com/embed/avatars/0.png";
|
{
|
||||||
|
// Direct messages are encapsulated within a special pseudo-guild for consistency
|
||||||
private static string GetIconUrl(Snowflake id, string iconHash)
|
public static Guild DirectMessages { get; } =
|
||||||
{
|
new(Snowflake.Zero, "Direct Messages", ImageCdn.GetFallbackUserAvatarUrl());
|
||||||
var extension = iconHash.StartsWith("a_", StringComparison.Ordinal)
|
|
||||||
? "gif"
|
|
||||||
: "png";
|
|
||||||
|
|
||||||
return $"https://cdn.discordapp.com/icons/{id}/{iconHash}.{extension}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Guild Parse(JsonElement json)
|
public static Guild Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
@@ -33,9 +23,10 @@ public record Guild(Snowflake Id, string Name, string IconUrl) : IHasId
|
|||||||
var name = json.GetProperty("name").GetNonNullString();
|
var name = json.GetProperty("name").GetNonNullString();
|
||||||
|
|
||||||
var iconUrl =
|
var iconUrl =
|
||||||
json.GetPropertyOrNull("icon")?.GetNonWhiteSpaceStringOrNull()?.Pipe(h => GetIconUrl(id, h)) ??
|
json.GetPropertyOrNull("icon")
|
||||||
GetDefaultIconUrl();
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
|
?.Pipe(h => ImageCdn.GetGuildIconUrl(id, h)) ?? ImageCdn.GetFallbackUserAvatarUrl();
|
||||||
|
|
||||||
return new Guild(id, name, iconUrl);
|
return new Guild(id, name, iconUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ public record Interaction(Snowflake Id, string Name, User User)
|
|||||||
public static Interaction Parse(JsonElement json)
|
public static Interaction Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
||||||
var name = json.GetProperty("name").GetNonWhiteSpaceString();
|
var name = json.GetProperty("name").GetNonNullString(); // may be empty, but not null
|
||||||
var user = json.GetProperty("user").Pipe(User.Parse);
|
var user = json.GetProperty("user").Pipe(User.Parse);
|
||||||
|
|
||||||
return new Interaction(id, name, user);
|
return new Interaction(id, name, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ using JsonExtensions.Reading;
|
|||||||
namespace DiscordChatExporter.Core.Discord.Data;
|
namespace DiscordChatExporter.Core.Discord.Data;
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/invite#invite-object
|
// https://discord.com/developers/docs/resources/invite#invite-object
|
||||||
public record Invite(
|
public record Invite(string Code, Guild Guild, Channel? Channel)
|
||||||
string Code,
|
|
||||||
Guild? Guild,
|
|
||||||
Channel? Channel)
|
|
||||||
{
|
{
|
||||||
public static string? TryGetCodeFromUrl(string url) =>
|
public static string? TryGetCodeFromUrl(string url) =>
|
||||||
Regex.Match(url, @"^https?://discord\.gg/(\w+)/?$").Groups[1].Value.NullIfWhiteSpace();
|
Regex.Match(url, @"^https?://discord\.gg/(\w+)/?$").Groups[1].Value.NullIfWhiteSpace();
|
||||||
@@ -17,9 +14,9 @@ public record Invite(
|
|||||||
public static Invite Parse(JsonElement json)
|
public static Invite Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
var code = json.GetProperty("code").GetNonWhiteSpaceString();
|
var code = json.GetProperty("code").GetNonWhiteSpaceString();
|
||||||
var guild = json.GetPropertyOrNull("guild")?.Pipe(Guild.Parse);
|
var guild = json.GetPropertyOrNull("guild")?.Pipe(Guild.Parse) ?? Guild.DirectMessages;
|
||||||
var channel = json.GetPropertyOrNull("channel")?.Pipe(c => Channel.Parse(c));
|
var channel = json.GetPropertyOrNull("channel")?.Pipe(c => Channel.Parse(c));
|
||||||
|
|
||||||
return new Invite(code, guild, channel);
|
return new Invite(code, guild, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||||
@@ -11,30 +10,36 @@ namespace DiscordChatExporter.Core.Discord.Data;
|
|||||||
// https://discord.com/developers/docs/resources/guild#guild-member-object
|
// https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||||
public partial record Member(
|
public partial record Member(
|
||||||
User User,
|
User User,
|
||||||
string Nick,
|
string? DisplayName,
|
||||||
IReadOnlyList<Snowflake> RoleIds) : IHasId
|
string? AvatarUrl,
|
||||||
|
IReadOnlyList<Snowflake> RoleIds
|
||||||
|
) : IHasId
|
||||||
{
|
{
|
||||||
public Snowflake Id => User.Id;
|
public Snowflake Id => User.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial record Member
|
public partial record Member
|
||||||
{
|
{
|
||||||
public static Member Parse(JsonElement json)
|
public static Member CreateFallback(User user) => new(user, null, null, []);
|
||||||
|
|
||||||
|
public static Member Parse(JsonElement json, Snowflake? guildId = null)
|
||||||
{
|
{
|
||||||
var user = json.GetProperty("user").Pipe(User.Parse);
|
var user = json.GetProperty("user").Pipe(User.Parse);
|
||||||
var nick = json.GetPropertyOrNull("nick")?.GetNonWhiteSpaceStringOrNull();
|
var displayName = json.GetPropertyOrNull("nick")?.GetNonWhiteSpaceStringOrNull();
|
||||||
|
|
||||||
var roleIds = json
|
var roleIds =
|
||||||
.GetPropertyOrNull("roles")?
|
json.GetPropertyOrNull("roles")
|
||||||
.EnumerateArray()
|
?.EnumerateArray()
|
||||||
.Select(j => j.GetNonWhiteSpaceString())
|
.Select(j => j.GetNonWhiteSpaceString())
|
||||||
.Select(Snowflake.Parse)
|
.Select(Snowflake.Parse)
|
||||||
.ToArray() ?? Array.Empty<Snowflake>();
|
.ToArray() ?? [];
|
||||||
|
|
||||||
return new Member(
|
var avatarUrl = guildId is not null
|
||||||
user,
|
? json.GetPropertyOrNull("avatar")
|
||||||
nick ?? user.Name,
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
roleIds
|
?.Pipe(h => ImageCdn.GetMemberAvatarUrl(guildId.Value, user.Id, h))
|
||||||
);
|
: null;
|
||||||
|
|
||||||
|
return new Member(user, displayName, avatarUrl, roleIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,22 @@ public partial record Message(
|
|||||||
IReadOnlyList<User> MentionedUsers,
|
IReadOnlyList<User> MentionedUsers,
|
||||||
MessageReference? Reference,
|
MessageReference? Reference,
|
||||||
Message? ReferencedMessage,
|
Message? ReferencedMessage,
|
||||||
Interaction? Interaction) : IHasId
|
Interaction? Interaction
|
||||||
|
) : IHasId
|
||||||
{
|
{
|
||||||
public bool IsReplyLike => Kind == MessageKind.Reply || Interaction is not null;
|
public bool IsSystemNotification =>
|
||||||
|
Kind is >= MessageKind.RecipientAdd and <= MessageKind.ThreadCreated;
|
||||||
|
|
||||||
|
public bool IsReply => Kind == MessageKind.Reply;
|
||||||
|
|
||||||
|
// App interactions are rendered as replies in the Discord client, but they are not actually replies
|
||||||
|
public bool IsReplyLike => IsReply || Interaction is not null;
|
||||||
|
|
||||||
|
public bool IsEmpty =>
|
||||||
|
string.IsNullOrWhiteSpace(Content)
|
||||||
|
&& !Attachments.Any()
|
||||||
|
&& !Embeds.Any()
|
||||||
|
&& !Stickers.Any();
|
||||||
|
|
||||||
public IEnumerable<User> GetReferencedUsers()
|
public IEnumerable<User> GetReferencedUsers()
|
||||||
{
|
{
|
||||||
@@ -71,21 +84,24 @@ public partial record Message
|
|||||||
var trailingEmbeds = embeds
|
var trailingEmbeds = embeds
|
||||||
.Skip(i + 1)
|
.Skip(i + 1)
|
||||||
.TakeWhile(e =>
|
.TakeWhile(e =>
|
||||||
e.Url == embed.Url &&
|
e.Url == embed.Url
|
||||||
e.Timestamp is null &&
|
&& e.Timestamp is null
|
||||||
e.Author is null &&
|
&& e.Author is null
|
||||||
e.Color is null &&
|
&& e.Color is null
|
||||||
string.IsNullOrWhiteSpace(e.Description) &&
|
&& string.IsNullOrWhiteSpace(e.Description)
|
||||||
!e.Fields.Any() &&
|
&& !e.Fields.Any()
|
||||||
e.Images.Count == 1 &&
|
&& e.Images.Count == 1
|
||||||
e.Footer is null
|
&& e.Footer is null
|
||||||
)
|
)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
if (trailingEmbeds.Any())
|
if (trailingEmbeds.Any())
|
||||||
{
|
{
|
||||||
// Concatenate all images into one embed
|
// Concatenate all images into one embed
|
||||||
var images = embed.Images.Concat(trailingEmbeds.SelectMany(e => e.Images)).ToArray();
|
var images = embed
|
||||||
|
.Images.Concat(trailingEmbeds.SelectMany(e => e.Images))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
normalizedEmbeds.Add(embed with { Images = images });
|
normalizedEmbeds.Add(embed with { Images = images });
|
||||||
|
|
||||||
i += trailingEmbeds.Length;
|
i += trailingEmbeds.Length;
|
||||||
@@ -107,42 +123,51 @@ public partial record Message
|
|||||||
public static Message Parse(JsonElement json)
|
public static Message Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
||||||
var kind = (MessageKind)json.GetProperty("type").GetInt32();
|
var kind = json.GetProperty("type").GetInt32().Pipe(t => (MessageKind)t);
|
||||||
var flags = (MessageFlags?)json.GetPropertyOrNull("flags")?.GetInt32() ?? MessageFlags.None;
|
|
||||||
var author = json.GetProperty("author").Pipe(User.Parse);
|
|
||||||
|
|
||||||
|
var flags =
|
||||||
|
json.GetPropertyOrNull("flags")?.GetInt32OrNull()?.Pipe(f => (MessageFlags)f)
|
||||||
|
?? MessageFlags.None;
|
||||||
|
|
||||||
|
var author = json.GetProperty("author").Pipe(User.Parse);
|
||||||
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
||||||
var editedTimestamp = json.GetPropertyOrNull("edited_timestamp")?.GetDateTimeOffset();
|
var editedTimestamp = json.GetPropertyOrNull("edited_timestamp")?.GetDateTimeOffsetOrNull();
|
||||||
var callEndedTimestamp = json
|
var callEndedTimestamp = json.GetPropertyOrNull("call")
|
||||||
.GetPropertyOrNull("call")?
|
?.GetPropertyOrNull("ended_timestamp")
|
||||||
.GetPropertyOrNull("ended_timestamp")?
|
?.GetDateTimeOffsetOrNull();
|
||||||
.GetDateTimeOffset();
|
|
||||||
|
|
||||||
var isPinned = json.GetPropertyOrNull("pinned")?.GetBooleanOrNull() ?? false;
|
var isPinned = json.GetPropertyOrNull("pinned")?.GetBooleanOrNull() ?? false;
|
||||||
var content = json.GetPropertyOrNull("content")?.GetStringOrNull() ?? "";
|
var content = json.GetPropertyOrNull("content")?.GetStringOrNull() ?? "";
|
||||||
|
|
||||||
var attachments =
|
var attachments =
|
||||||
json.GetPropertyOrNull("attachments")?.EnumerateArrayOrNull()?.Select(Attachment.Parse).ToArray() ??
|
json.GetPropertyOrNull("attachments")
|
||||||
Array.Empty<Attachment>();
|
?.EnumerateArrayOrNull()
|
||||||
|
?.Select(Attachment.Parse)
|
||||||
|
.ToArray() ?? [];
|
||||||
|
|
||||||
var embeds = NormalizeEmbeds(
|
var embeds = NormalizeEmbeds(
|
||||||
json.GetPropertyOrNull("embeds")?.EnumerateArrayOrNull()?.Select(Embed.Parse).ToArray() ??
|
json.GetPropertyOrNull("embeds")?.EnumerateArrayOrNull()?.Select(Embed.Parse).ToArray()
|
||||||
Array.Empty<Embed>()
|
?? []
|
||||||
);
|
);
|
||||||
|
|
||||||
var stickers =
|
var stickers =
|
||||||
json.GetPropertyOrNull("sticker_items")?.EnumerateArrayOrNull()?.Select(Sticker.Parse).ToArray() ??
|
json.GetPropertyOrNull("sticker_items")
|
||||||
Array.Empty<Sticker>();
|
?.EnumerateArrayOrNull()
|
||||||
|
?.Select(Sticker.Parse)
|
||||||
|
.ToArray() ?? [];
|
||||||
|
|
||||||
var reactions =
|
var reactions =
|
||||||
json.GetPropertyOrNull("reactions")?.EnumerateArrayOrNull()?.Select(Reaction.Parse).ToArray() ??
|
json.GetPropertyOrNull("reactions")
|
||||||
Array.Empty<Reaction>();
|
?.EnumerateArrayOrNull()
|
||||||
|
?.Select(Reaction.Parse)
|
||||||
|
.ToArray() ?? [];
|
||||||
|
|
||||||
var mentionedUsers =
|
var mentionedUsers =
|
||||||
json.GetPropertyOrNull("mentions")?.EnumerateArrayOrNull()?.Select(User.Parse).ToArray() ??
|
json.GetPropertyOrNull("mentions")?.EnumerateArrayOrNull()?.Select(User.Parse).ToArray()
|
||||||
Array.Empty<User>();
|
?? [];
|
||||||
|
|
||||||
var messageReference = json.GetPropertyOrNull("message_reference")?.Pipe(MessageReference.Parse);
|
var messageReference = json.GetPropertyOrNull("message_reference")
|
||||||
|
?.Pipe(MessageReference.Parse);
|
||||||
var referencedMessage = json.GetPropertyOrNull("referenced_message")?.Pipe(Parse);
|
var referencedMessage = json.GetPropertyOrNull("referenced_message")?.Pipe(Parse);
|
||||||
var interaction = json.GetPropertyOrNull("interaction")?.Pipe(Interaction.Parse);
|
var interaction = json.GetPropertyOrNull("interaction")?.Pipe(Interaction.Parse);
|
||||||
|
|
||||||
@@ -166,4 +191,4 @@ public partial record Message
|
|||||||
interaction
|
interaction
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ public enum MessageFlags
|
|||||||
HasThread = 32,
|
HasThread = 32,
|
||||||
Ephemeral = 64,
|
Ephemeral = 64,
|
||||||
Loading = 128
|
Loading = 128
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,3 @@ public enum MessageKind
|
|||||||
ThreadCreated = 18,
|
ThreadCreated = 18,
|
||||||
Reply = 19
|
Reply = 19
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MessageKindExtensions
|
|
||||||
{
|
|
||||||
public static bool IsSystemNotification(this MessageKind c) => (int)c is >= 1 and <= 18;
|
|
||||||
}
|
|
||||||
@@ -9,21 +9,18 @@ public record MessageReference(Snowflake? MessageId, Snowflake? ChannelId, Snowf
|
|||||||
{
|
{
|
||||||
public static MessageReference Parse(JsonElement json)
|
public static MessageReference Parse(JsonElement json)
|
||||||
{
|
{
|
||||||
var messageId = json
|
var messageId = json.GetPropertyOrNull("message_id")
|
||||||
.GetPropertyOrNull("message_id")?
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
.GetNonWhiteSpaceStringOrNull()?
|
?.Pipe(Snowflake.Parse);
|
||||||
.Pipe(Snowflake.Parse);
|
|
||||||
|
|
||||||
var channelId = json
|
var channelId = json.GetPropertyOrNull("channel_id")
|
||||||
.GetPropertyOrNull("channel_id")?
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
.GetNonWhiteSpaceStringOrNull()?
|
?.Pipe(Snowflake.Parse);
|
||||||
.Pipe(Snowflake.Parse);
|
|
||||||
|
|
||||||
var guildId = json
|
var guildId = json.GetPropertyOrNull("guild_id")
|
||||||
.GetPropertyOrNull("guild_id")?
|
?.GetNonWhiteSpaceStringOrNull()
|
||||||
.GetNonWhiteSpaceStringOrNull()?
|
?.Pipe(Snowflake.Parse);
|
||||||
.Pipe(Snowflake.Parse);
|
|
||||||
|
|
||||||
return new MessageReference(messageId, channelId, guildId);
|
return new MessageReference(messageId, channelId, guildId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ public record Reaction(Emoji Emoji, int Count)
|
|||||||
|
|
||||||
return new Reaction(emoji, count);
|
return new Reaction(emoji, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,12 @@ public record Role(Snowflake Id, string Name, int Position, Color? Color) : IHas
|
|||||||
var name = json.GetProperty("name").GetNonNullString();
|
var name = json.GetProperty("name").GetNonNullString();
|
||||||
var position = json.GetProperty("position").GetInt32();
|
var position = json.GetProperty("position").GetInt32();
|
||||||
|
|
||||||
var color = json
|
var color = json.GetPropertyOrNull("color")
|
||||||
.GetPropertyOrNull("color")?
|
?.GetInt32OrNull()
|
||||||
.GetInt32()
|
?.Pipe(System.Drawing.Color.FromArgb)
|
||||||
.Pipe(System.Drawing.Color.FromArgb)
|
|
||||||
.ResetAlpha()
|
.ResetAlpha()
|
||||||
.NullIf(c => c.ToRgb() <= 0);
|
.NullIf(c => c.ToRgb() <= 0);
|
||||||
|
|
||||||
return new Role(id, name, position, color);
|
return new Role(id, name, position, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user