> For the complete documentation index, see [llms.txt](https://cyr1en.gitbook.io/commandprompter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cyr1en.gitbook.io/commandprompter/features/post-command.md).

# Post Command

`PostCommand` allows you to execute one or more commands automatically after the player completes or cancels the prompt session.

{% hint style="info" %}
By default, post commands are run by the player who initiated the session. Even when using [Console Delegate](/commandprompter/features/console-delegate.md), they run as the player by default unless explicitly marked with `@console`.
{% endhint %}

***

## Syntax

Add `<!command>` to your command string.

* **Basic Example:**

  ```
  /sampleCommand <Input text> <!say hello world!>
  ```

  Runs `/say hello world!` upon completion.

***

## Placeholders

You can reference prompt answers using placeholders. The format depends on the command type:

### 1. Inline Post Commands

Defined directly in the command string. Uses **zero-based indexing** (`{0}`, `{1}`, etc.).

* **Example:** `/sampleCommand <What to say> <!say {0}>` (If input is `Hello`, runs `/say Hello`).

### 2. Preset Post Commands

Defined in `presets.json` and referenced via `<!@preset_name>`. Uses **one-based indexing** (`{input:1}`, `{input:2}`) or `{input}` (alias for first input).

* Supported variables:
  * `{input}` or `{input:1}` - First prompt answer.
  * `{input:2}` - Second prompt answer.
  * `{player}` - Name of the executing player.
  * PlaceholderAPI placeholders (e.g., `%player_name%`).

***

## Advanced Features

### Multiple Post Commands

You can append multiple post command tags:

```
/time set <Time> <!broadcast Time set to {0}> <!weather clear>
```

### Delayed Execution

Add a tick delay using `:<ticks>` after the `!`:

```
/op <p:Player> <!:100 deop {0}>
```

*(Gives OP, then removes it after 100 ticks / 5 seconds).*

### Run on Cancellation

Execute a command if the player cancels the prompt by using `!!` instead of `!`:

```
/mute <a:Player> <!!:20 punish>
```

*(Re-opens the `/punish` menu 20 ticks after cancellation).*

### Piping Executors

Pipe a post command to run as a different executor by appending `@player` or `@console`.

* **Format:**
  * `<!command @player>` - Executes command as the player.
  * `<!command @console>` - Executes command as the console.
* **Example:**

  ```yaml
  # Executed by console:
  /consoledelegate %target_player% gamemode <Gamemode> %target_player% <!say I am now {0} @player>
  ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cyr1en.gitbook.io/commandprompter/features/post-command.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
