# Purge Messages

<figure><img src="https://1937909199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lm_hW5MApY3J0lRhi0M%2Fuploads%2FlHmWrRjYeC8baO5ngvUY%2Fimage_2024-05-30_162604851.png?alt=media&#x26;token=3712d538-b1de-432f-8bd5-6b2347227adc" alt=""><figcaption></figcaption></figure>

The purge messages action block will allow you purge a specific amount of messages in a specfic channel.

{% hint style="warning" %}
If messages are older than 14 days, they can't be deleted, unless you're deleting only 1 message.
{% endhint %}

## **Channel**

<figure><img src="https://1937909199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lm_hW5MApY3J0lRhi0M%2Fuploads%2FcsxUWoxUYimLKC7jpdZv%2Fimage_2024-05-29_124430934.png?alt=media&#x26;token=33976de1-4052-4ebe-9cef-8bd10735d420" alt=""><figcaption></figcaption></figure>

{% tabs %}
{% tab title="Channel the command was run in" %}
This type will purge messages in the channel that the command / event was executed in or where a [button](https://botghost.com/docs/custom-commands-and-events/actions/legacy-reply-actions/send-a-message-with-attached-buttons/buttons) / [menu option](https://botghost.com/docs/custom-commands-and-events/actions/legacy-reply-actions/send-a-message-with-a-select-menu/menu-option) was clicked.
{% endtab %}

{% tab title="Channel ID or Option" %}
Selecting this dropdown will target a specific channel ID or Option for where the messages will be purged in.

### **Channel ID or Option**

This field is where you input a plain channel ID / [variable](https://botghost.com/docs/custom-commands-and-events/variables) or a [channel option](https://botghost.com/docs/custom-commands-and-events/options/channel-option).&#x20;

<figure><img src="https://1937909199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lm_hW5MApY3J0lRhi0M%2Fuploads%2FeoSoCwX5ejmV9H3d3h7H%2Fimage_2024-05-29_124802605.png?alt=media&#x26;token=04309177-be40-4742-974f-2ec0fac51e3b" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## **Amount**

This field is the amount of messages that will be purged. It only accepts integers / [variables](https://botghost.com/docs/custom-commands-and-events/variables) that return a integer.&#x20;

<figure><img src="https://1937909199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lm_hW5MApY3J0lRhi0M%2Fuploads%2FGQ3WkDph2tYEokJgnWwm%2Fimage_2024-05-29_125018136.png?alt=media&#x26;token=f1d8e9b0-88bd-4c3e-8e8f-fa35e06ca2af" alt=""><figcaption></figcaption></figure>

## Enable Success/Error Handles

Enable Success / Error Handles to detect success and errors inside of the action block. This allows you to run different actions if something goes wrong with your action. Inside of the handle, there are 2 different paths which are used to detect the outcome of the action. The green path on the bottom left side of the block indicates success, while the red path on the bottom right side of the block indicates error. You may attach action blocks to each side of the handle to get the outcome of your action block.

<figure><img src="https://1937909199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lm_hW5MApY3J0lRhi0M%2Fuploads%2FfEZAijxwiWs3yk4C3iLK%2Fimage.png?alt=media&#x26;token=52ffafb0-0e8c-4980-a111-0999d8451789" alt=""><figcaption></figcaption></figure>

The Success/Error Handles feature includes 3 different error variables you can use to get information on why the action block encountered an error. Check them out [here](https://botghost.com/docs/variables#error-variables).

<figure><img src="https://1937909199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lm_hW5MApY3J0lRhi0M%2Fuploads%2FgBCbX0HtGmaNhGXARsoA%2Fimage.png?alt=media&#x26;token=57dbe5f3-6efc-47af-9022-5196739573c3" alt=""><figcaption></figcaption></figure>
