2023-01-26 21:11:51 -05:00
# Message filters
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.
2023-06-08 09:48:32 -04:00
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 ).
2023-01-26 21:11:51 -05:00
## Examples
- Filter by user
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
from:Tyrrrz
```
- Filter by user (with discriminator)
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
from:Tyrrrz#1234
```
- Filter by message content (allowed values: `link` , `embed` , `file` , `video` , `image` , `sound` )
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
has:image
```
- Filter by mentioned user (same rules apply as with `from:` filter)
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
mentions:Tyrrrz#1234
```
- Filter by contained text (has word "hello" and word "world" somewhere in the message text):
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
hello world
```
- Filter by contained text (has the string "hello world" somewhere in the message text):
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
"hello world"
```
- Combine multiple filters ('and'):
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
from:Tyrrrz has:image
```
- Same thing but with an explicit operator:
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
from:Tyrrrz & has:image
```
- Combine multiple filters ('or'):
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
from:Tyrrrz | from:"96-LB"
```
- Combine multiple filters using groups:
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
(from:Tyrrrz | from:"96-LB") has:image
```
- Negate a filter:
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
-from:Tyrrrz | -has:image
```
- Negate a grouped filter:
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
-(from:Tyrrrz has:image)
```
2023-01-27 03:06:03 -05:00
- Escape special characters (`-` is escaped below, so it's not parsed as negation operator):
2023-01-26 21:11:51 -05:00
2023-09-29 07:53:52 -04:00
```console
2023-01-26 21:11:51 -05:00
from:96\-LB
```
2023-06-08 09:48:32 -04:00
## CLI Caveats
2023-01-26 21:11:51 -05:00
2023-06-08 09:48:32 -04:00
In most cases, you will need to enclose your filter in quotes (`"`) to escape characters that may have special meaning in your shell:
2023-01-26 21:11:51 -05:00
2023-09-29 07:53:52 -04:00
```console
2024-04-27 19:24:23 -04:00
$ ./DiscordChatExporter.Cli export [...] --filter "from:Tyrrrz has:image"
2023-06-08 09:48:32 -04:00
```
If you need to include quotes inside the filter itself as well, use single quotes (`'`) for those instead:
2023-09-29 07:53:52 -04:00
```console
2024-04-27 19:24:23 -04:00
$ ./DiscordChatExporter.Cli export [...] --filter "from:Tyrrrz 'hello world'"
2023-01-26 21:29:36 -05:00
```
2023-06-08 09:48:32 -04:00
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 (`-`):
2023-09-29 07:53:52 -04:00
```console
2024-04-27 19:24:23 -04:00
$ ./DiscordChatExporter.Cli export [...] --filter ~from:Tyrrrz
2023-09-29 07:53:52 -04:00
```