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

# ⌛ 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 %}
