> For the complete documentation index, see [llms.txt](https://miulien.gitbook.io/bot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://miulien.gitbook.io/bot/en/utilities/clear.md).

# Clear Messages (clear)

Use `/clear` or `m!clear` to delete messages from the **current channel**. Filter by author and optionally include pinned messages.

## 🧹 Examples

| Example                             | What it does                                     |
| ----------------------------------- | ------------------------------------------------ |
| `/clear count:10`                   | Delete up to ten of the latest matching messages |
| `/clear count:20 member:@user`      | Delete up to 20 messages from that user          |
| `/clear count:5 include_pinned:yes` | Allow pinned messages in the deletion            |
| `m!clear 10`                        | Delete ten messages with a prefix command        |
| `m!clear 20 @user`                  | Only delete messages by that user                |

You can target **1–100 messages per request**, in the channel where the command runs.

## 🔎 Parameters

* **Count (required):** From 1 to 100.
* **Member (optional):** Filter messages by author.
* **Include pinned (optional):** **Off by default**; enable it explicitly to delete pinned messages.

When a member is specified, the count refers to **matching messages**, not the number of recent messages examined. Miulien searches backwards until it finds up to the requested number. If fewer are found, it deletes what is available and reports the shortfall.

## 📌 Pinned and older messages

Pinned messages are protected unless you enable **Include pinned**. Discord does not support bulk deletion of messages older than **14 days**:

* Messages up to 14 days old are deleted in batches when possible.
* Older messages are deleted individually and may take longer.
* If bulk deletion fails, Miulien attempts individual deletions.

## 💬 Command and result messages

With `m!clear`, Miulien attempts to remove the command message as an **extra deletion** that does not count toward the requested amount.

The result summarizes the successful deletion count, selected filters, shortfalls, and any failures.

**Warning:** Deleted messages cannot be restored by Miulien. Check your count and pinned-message option before running the command.

## 🔐 Permissions

You must either have Discord's **Manage Messages** permission in the current channel or belong to a role explicitly authorized to use `clear` through Miulien `permissions`.

Miulien itself must also have **Manage Messages** and **Read Message History** permissions in that channel. An authorized user cannot bypass missing bot permissions.

> This command requires a server channel with message history. It does not work in DMs.
