# Post Command

CommandPrompter now allows you to add a command to execute after all of the prompts have been completed, called `PostCommand`

{% hint style="info" %}
Examples below are in the context of a player. If you're using [Console Delegate](/commandprompter/features/console-delegate.md), the commands will be sent as console, making some commands have the wrong arguments. Adjust your command arguments respectively.
{% endhint %}

### Format

A `PostCommand` is an assignable `PromptQueueArgument` with the key `-exa` , which stands for `execute after`, which tells the parser to add a command that the plugin is going to execute after all of the prompts have been completed.

Here is an example:

```
/sampleCommand <this is a text prompt> <-exa say hello world!>
```

This should execute the command `/say hello world!` after completion.

### Placeholders

An additional feature is the ability to put placeholders if you want to use one of the answers from the prompts. The placeholder format is `p:<index>`. Since I'm using the index, the index of the first prompt will always be `0`.

```
/sampleCommand <what do you want to say> <-exa say p:0>
```

Let's say, I enter `Hello World!` on the text prompt, the command to execute at the end should be `/say Hello World!`

### Multiple Post Command

Another feature available starting from `2.3.0` is the ability to have more than one `Post Command`. Here's an example of this.

```
/time set <enter time to set> <-exa broadcast Time set to &cp:0> <-exa weather clear> <-exa broadcast Weather cleared!>
```

The main command is `/time set` however, we have three post commands that also clear the weather and broadcast that the time and weather have been changed.

### Delayed Post Command

You can add a tick delay for a post command by adding a `:<ticks>` after the `exa`

```
/op <-p who do you want to op?> <-exa:100 deop p:0>
```

With the example above, we ask which player to give the operator to. But after 100 ticks (5 seconds), we remove that operator status from that player.

### Post Command on completion cancel

This is another useful feature when you want to execute a command when the player cancels the command completion. This gives you the ability to reopen another menu if the prompt is canceled.

```
/mute <-a who do you want to mute?> <-exac:20 punish>
```

The example above will re-open the `punish` menu if the anvil prompt gets canceled.

### Piping Post Command to a different executor

{% hint style="info" %}
To prevent regular (non-op) players from abusing this system through chat, post command piping will only work if the command sender is the console; therefore, you have to use [PlayerDelegate](/commandprompter/features/player-delegate.md) or [ConsoleDelegate](/commandprompter/features/console-delegate.md).
{% endhint %}

For instances where you need the post command to have a different command executor, you can do so by piping them to a different executor. &#x20;

Format:

```
-exa(c):<delay>|p
-exa(c):<delay>|c -> PCM as Console
```

Example:

{% code overflow="wrap" fullWidth="false" %}

```yaml
[console]consoledelegate %target_player% gamemode <what gamemode do you want> %target_player% <-exa|p say I am now p:0>
```

{% endcode %}

With the example above, the console delegates the prompt to the `target_player`  and once the command is done, `target_player` will say "I am now \[gamemode]".


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
