# Templating

To take advantage of Chatter to its fullest, the message template syntax should be understood. Most add-ons will allow you to write custom messages. For example, you may wish to reference the player's name or substitute the current date & time.

### Syntax

A token is a fixed name that is replaced with its actual value. In order to prevent unintentional replacements, we wrap the token name with `${` and `}`.

{% hint style="info" %}
You can find the available tokens along with the config entry!
{% endhint %}

For example, say we are allowed to substitute the player's name into our message, and the token name is described as `player`. We can just add `${player}` anywhere in our message!

If a token accepts formatting arguments, we can add them after a colon, e.g. `${token:format here}`.

### Types

#### Plain Text

There is nothing fancy here, just use `${token}`.

#### Duration

By default, a duration token of `${duration}` will use words. However, you can customise the format, e.g.

```javascript
${duration:m' minutes 's.SSS' seconds'} // 107 minutes 59.251 seconds
```

| Symbol | Meaning         | Examples      |
| ------ | --------------- | ------------- |
| y      | years           | 0             |
| M      | months          | 0             |
| d      | days            | 1             |
| H      | hours           | 17            |
| m      | minutes         | 30            |
| s      | seconds         | 59            |
| S      | milliseconds    | 314           |
| '      | escape for text | 'custom text' |

{% hint style="info" %}
You can find the full list of duration patterns [here](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/time/DurationFormatUtils.html).
{% endhint %}

#### Date & Time

To use a date & time token, you'll **need to** specify the format, e.g.

```javascript
${datetime:d. MMMM yyyy h':'mm a} // 27. March 2021 2:14 PM
```

| Symbol | Meaning                    | Examples      |
| ------ | -------------------------- | ------------- |
| yyyy   | year-of-era                | 2004          |
| yy     | year-of-era                | 04            |
| MMMM   | month-of-year              | July          |
| MMM    | month-of-year              | Jul           |
| MM     | month-of-year              | 07            |
| M      | month-of-year              | 7             |
| dd     | day-of-month               | 04            |
| d      | day-of-month               | 4             |
| EEEE   | day-of-week                | Tuesday       |
| EEE    | day-of-week                | Tue           |
| ee     | day-of-week                | 02            |
| e      | day-of-week                | 2             |
| a      | am-pm-of-day               | PM            |
| hh     | clock-hour-of-am-pm (1-12) | 08            |
| h      | clock-hour-of-am-pm (1-12) | 8             |
| HH     | hour-of-day (0-23)         | 00            |
| H      | hour-of-day (0-23)         | 0             |
| mm     | minute-of-hour             | 02            |
| m      | minute-of-hour             | 2             |
| ss     | second-of-minute           | 07            |
| s      | second-of-minute           | 7             |
| SSS    | fraction-of-second         | 878           |
| SS     | fraction-of-second         | 88            |
| S      | fraction-of-second         | 9             |
| '      | escape for text            | 'custom text' |
| ''     | single-quote               | '             |

{% hint style="info" %}
You can find the full list of date patterns [here](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns).
{% endhint %}


---

# 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://axieum.gitbook.io/chatter-for-minecraft/misc/templating.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.
