# ⌛ Command Cooldowns

## About

In **SunLight** you can create **custom cooldowns** for **any command** on your server!

Cooldown configuration is located in the **command-map.yml** -> `Cooldowns` config file section.

{% hint style="warning" %}
Unfortunately, it's not possible to detect if command execution was successful or not, so the cooldown will apply even when you get "error" messages, such as "Invalid Player", "Incorrect Usage", etc.
{% endhint %}

## Setup

Cooldown entry consist of the following options:

* **Commands**. List of **command names** to which this cooldown is applicable. If a command has multiple aliases (such as /crate, /crates, /case, etc.), you can use only one of them.
* **Patterns**. List of command patterns to trigger the cooldown. It's a list of **full** command **messages** used by players. You can use `|` to make the pattern trigger on **multiple variants** of a specific argument. You can use `?` instead of argument name if you can't predict it.
* **Cooldown**. Map of rank based cooldown values (in seconds). If player has no rank, it will look for a `default` entry. Otherwise no cooldown will be applied. Set to `-1` to make command one-time.

{% code fullWidth="true" %}

```yaml
Cooldowns:
  heal:
    Commands: heal,health # Applies to "/heal" and "/health" commands (including aliases, such as "/hp").
    Patterns:
    - hp|health restore # Applies to both "/health restore" and "/hp restore".
    - heal # Applies to "/heal".
    Cooldown:
      default: 60 # 60 seconds cooldown for all players
      gold: 30 # 30 seconds cooldown for players with "gold" permission group.
  gamemode:
    Commands: gamemode,gmc,gms,gma,gmsp # Applies to "/gamemode" commands (including aliases, such as "/gm").
    Patterns:
    - gamemode|gm ? # Applies to all "/gamemode/gm creative/survival/adventure/spectator" commands, but not on the "/gamemode" itself.
    - gms|gmc|gma|gmsp # Applies to /gmc, /gma, /gms, /gmsp commands.
    Cooldown:
      default: 60
      gold: 30
```

{% endcode %}


---

# 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://nightexpress.gitbook.io/sunlight/general/command-cooldowns.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.
