> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mira.lgbt/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto Purge

> Automatically purge messages in a channel every so often, matching whatever criteria you set.

<Info>You must have the **Manage Channels** and **Manage Messages** permissions.</Info>

## Usage

```a Syntax theme={null}
purge add <channel> <interval> [flags]
```

```a Example theme={null}
purge add #general 1h -tos -or -music
```

<Tip>
  `<>` marks a **required** argument, `[]` marks an **optional** one. Don't type the brackets themselves.
</Tip>

<Info>
  The interval must be at least **1 hour** and at most **14 days**. See [Durations](/reference/syntax/durations) for accepted syntax.
</Info>

## Flags

Flags combine with **AND**, so a message has to match all of them to be removed. Add `-or` to remove messages matching **any** of them instead.

### Matching content

| Flag        | Matches a message that         |
| ----------- | ------------------------------ |
| `-tos`      | Breaks Discord's TOS           |
| `-invites`  | Contains a Discord invite link |
| `-links`    | Contains a URL                 |
| `-embeds`   | Has an embed                   |
| `-files`    | Has a file attachment          |
| `-music`    | Has an audio attachment        |
| `-voice`    | Is a voice message             |
| `-mentions` | Mentions a user                |
| `-emojis`   | Contains an emoji              |
| `-stickers` | Contains a sticker             |

### Matching author

| Flag            | Matches a message that         |
| --------------- | ------------------------------ |
| `-bots`         | Was sent by a bot              |
| `-humans`       | Was sent by a human            |
| `-webhooks`     | Was sent by a webhook          |
| `-system`       | Was sent by Discord itself     |
| `--user <user>` | Was sent by a specific user    |
| `--role <role>` | Was sent by anyone with a role |

### Matching text

| Flag                  | Matches a message that |
| --------------------- | ---------------------- |
| `--contains <text>`   | Contains this text     |
| `--startswith <text>` | Starts with this text  |
| `--endswith <text>`   | Ends with this text    |

<Tip>
  Pass multiple terms by separating them with `|` or `,`. For example, `--contains leaked|leaking` matches either word.
</Tip>

### Modifiers

| Flag                | Description                                                |
| ------------------- | ---------------------------------------------------------- |
| `-or`               | Remove messages matching any criteria instead of all.      |
| `--after <link>`    | Only purge messages sent after this message link.          |
| `--amount <number>` | Max messages to scan per run. Default `3500`, max `15000`. |

## Behavior

* A channel can only have **one** scheduled purge at a time. Running `purge add` on a channel that already has one replaces the old settings.
* The first purge runs one full interval after you set it up, not immediately.
* Pinned messages are never removed, no matter which flags are set.
* `--amount` is how many recent messages the bot searches through on each run. If more messages were sent during the interval than the amount, only the most recent ones get checked and the rest are left alone. Raise it on busy channels.

<Warning>
  Discord only allows bots to bulk delete messages under **14 days** old. Anything older is skipped and stays in the channel. This is a Discord limitation, not something the bot can work around, and it's why the interval caps out at `14d`.
</Warning>

## Related commands

| Command                  | Description                                            |
| ------------------------ | ------------------------------------------------------ |
| `purge remove <channel>` | Removes the scheduled purge from a channel.            |
| `purge list`             | Lists every scheduled purge in the server.             |
| `purge clear`            | Removes every scheduled purge. Prompts you to confirm. |
