---
url: https://docs.juniper.bot/en/message-templates/types.md
description: Basic Data Types used in Template Engine
---

[Number]: /en/message-templates/types/index#literals

[String]: /en/message-templates/types/index#literals

[Boolean]: /en/message-templates/types/index#literals

[List]: /en/message-templates/types/index#lists

[Map]: /en/message-templates/types/index#maps

[DateTime]: /en/message-templates/types/index#datetime

[TwitchChannel]: /en/message-templates/types/subscriptions/twitch#twitch-channel

[TwitchStream]: /en/message-templates/types/subscriptions/twitch#twitch-stream

[TwitchGame]: /en/message-templates/types/subscriptions/twitch#twitch-game

[YouTubeChannel]: /en/message-templates/types/subscriptions/youtube#youtube-channel

[YouTubeVideo]: /en/message-templates/types/subscriptions/youtube#youtube-video

[VkWallPost]: /en/message-templates/types/subscriptions/vk#vkwallpost

[Rank]: /en/message-templates/types/discord/rank

[Guild]: /en/message-templates/types/discord/guild

[Member]: /en/message-templates/types/discord/member

[Role]: /en/message-templates/types/discord/role

[Message]: /en/message-templates/types/discord/message

[Attachment]: /en/message-templates/types/discord/attachment

[Embed]: /en/message-templates/types/discord/embed

[Activity]: /en/message-templates/types/discord/activity

[MemberVoiceState]: /en/message-templates/types/discord/member-voice-state

[MemberPrimaryGuild]: /en/message-templates/types/discord/member-primary-guild

[MenuBuilder]: /en/message-templates/types/discord/menu-builder

[UserFlag]: /en/message-templates/types/discord/user-flag

[Permission]: /en/message-templates/types/discord/permission

[Category]: /en/message-templates/types/discord/category

[TextChannel]: /en/message-templates/types/discord/text-channel

[VoiceChannel]: /en/message-templates/types/discord/voice-channel

[NewsChannel]: /en/message-templates/types/discord/news-channel

[StageChannel]: /en/message-templates/types/discord/stage-channel

[ForumChannel]: /en/message-templates/types/discord/forum-channel

[MediaChannel]: /en/message-templates/types/discord/media-channel

[ThreadChannel]: /en/message-templates/types/discord/thread-channel

[Page]: /en/message-templates/types/storage/page

[GuildIndex]: /en/message-templates/types/storage/guild-index

[GuildIndexEntry]: /en/message-templates/types/storage/guild-index-entry

[GuildIndexes]: /en/message-templates/types/storage/guild-indexes

[MemberAttribute]: /en/message-templates/types/storage/member-attribute

[MemberAttributes]: /en/message-templates/types/storage/member-attributes

[Arguments]: /en/message-templates/types/custom-commands/arguments

[Parameters]: /en/message-templates/types/custom-commands/parameters

[Component]: /en/message-templates/types/custom-commands/component

[Modal]: /en/message-templates/types/custom-commands/modal

# Basic Data Types

This article describes all basic data types used in the JuniperBot Template Engine.

Some methods may have an invoke quota. Quota means how many times this method can be invoked per single template.
Attempts to invoke that exceed the specified quota will be ignored and will not take any action.

## Literals { #literals }

Literals are the most basic expressions, check the table below:

| Name           | Example                                                |
|----------------|--------------------------------------------------------|
| Float          | `-1.5`, `5.7`, `1.0`                                   |
| Integer        | `-10`, `56`, `0`                                       |
| Null Reference | `null`                                                 |
| Boolean        | `true` или `false`                                     |
| String         | `"string in double brackets"``'apostrophe string'` |
| Character      | `'g'`                                                  |

## Lists { #lists }

There are two ways to specify a list in Template Engine. It can be either by enumeration or by comprehension.

1. To specify a list by enumeration, you need to provide every single element of the list, as shown below:

   ```
   [1, 2, 3]
   ```

   The list defined this way is mutable. It does support [methods](#lists-methods) to add, remove, replace elements and
   clear the list.

2. To specify a list by comprehension, you just need to specify both the beginning and the ending elements of the list:

   ```
   [1..3]
   ```

   The list defined this way is **immutable**. It's kind of a tuple that is very convenient to use in
   [loops](../advanced/tags#loops).

::: warning
The maximum list size is 250 elements.
:::

### Methods { #lists-methods }

[Type Conversion](type-convert) **does not apply** for list methods:

```template
{{ [1..3].contains(1) }} - {{ [1..3].contains('1') }}
```

This example will print `true - false`.

When working with lists, especially with methods involving searching, you should always keep the data type in mind.

::: warning
Modifying methods are only available for lists created by enumeration like the example above.
:::

| Method                    | Parameters                                                                    | Returns                             | Description                                                                                                                                              |
|:--------------------------|:------------------------------------------------------------------------------|:------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `add(Element)`            | \[Number]\[String]\[Boolean]                                           | \[Boolean]                           | Appends the specified element to the end of list.Returns `true` if element has been added.                                                          |
| `addIfAbsent(Element)`    | \[Number]\[String]\[Boolean]                                           | \[Boolean]                           | Appends the specified element to the end of list if the list doesn't contain it yet.Returns `true` if element has been added.                       |
| `addAll(List)`            | \[List]                                                                        | \[Boolean]                           | Appends all of the elements in the specified collection to the end of this list.Returns `true` if list has changed in result.                       |
| `replace(Index, Element)` | Index:\[Number]Element:\[Number]\[String]\[Boolean] | \[Number]\[String]\[Boolean] | Replaces the element at the specified position in this list with the specified element.Returns the element previously at the specified position.    |
| `remove(Element)`         | \[Number]\[String]\[Boolean]                                           | \[Boolean]                           | Removes the first occurrence of the specified element from this list, if it is present.Returns `true` if this list contained the specified element. |
| `removeAll(List)`         | \[List]                                                                        | \[Boolean]                           | Removes all elements that are contained in the specified list.Returns `true` if at least one element has been removed.                              |
| `removeAt(Index)`         | \[Number]                                                                      | \[Number]\[String]\[Boolean] | Removes the element at the specified position in this list.Returns the element that was removed from the list.                                      |
| `contains(Element)`       | \[Number]\[String]\[Boolean]                                           | \[Boolean]                           | Returns `true` if list contains the specified element.                                                                                                   |
| `containsAll(List)`       | \[List]                                                                        | \[Boolean]                           | Returns `true` if list contains all of the elements in the specified list.                                                                               |
| `containsAny(List)`       | \[List]                                                                        | \[Boolean]                           | Returns `true` if list contains any of the elements in the specified list.                                                                               |
| `indexOf(Element)`        | \[Number]\[String]\[Boolean]                                           | \[Number]                            | Returns the index of the first occurrence of the specified element, or -1 if this list does not contain the element.                                     |
| `countOf(Element)`        | \[Number]\[String]\[Boolean]                                           | \[Number]                            | Returns the amount of occurrences of the specified element.                                                                                              |
| `clear()`                 | -                                                                             | -                                   | Removes all of the elements from this list.                                                                                                              |

## Maps { #maps }

It is also possible to represent collections of key and value pairs, so-called maps, where keys can either be
Identifiers or Strings and values can take form of any kind of expression:

```
{ key1: 'value1', 'key 2': 'value2' }
```

Keep in mind that identifiers used to represent the key elements are not used as variable placeholders, instead, they
are converted to their String representation. For example, the identifier `key1` shown above will be converted to the
String value `"key1"`.

::: warning
The maximum map size is 250 entries.
:::

### Methods { #maps-methods }

[Type Conversion](type-convert) **does not apply** for map methods.

```template
{% set map = { key: 1 } %}
{{ map.containsValue(1) }} - {{ map.containsValue('1') }}
```

This example will print `true - false`.

When working with maps, especially with methods involving searching values, you should always keep the data type in mind.

::: warning
Following methods are only available for maps created manually like the example above.
:::

| Method                    | Parameters                                                                | Returns                             | Description                                                                                                                                                                                                                                                                |
|:--------------------------|:--------------------------------------------------------------------------|:------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `put(Key, Value)`         | Key:\[String]Value:\[Number]\[String]\[Boolean] | \[Number]\[String]\[Boolean] | Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value.Returns the previous value associated with key, or `null` if there was no mapping for key. |
| `putAll(Map)`             | \[Map]                                                                     | -                                   | Copies all of the mappings from the specified map to this map.                                                                                                                                                                                                             |
| `putIfAbsent(Key, Value)` | Key:\[String]Value:\[Number]\[String]\[Boolean] | \[Number]\[String]\[Boolean] | If the specified key is not already associated with a value, associates it with the given value and returns `null`, otherwise returns the current value.                                                                                                                   |
| `remove(Key)`             | \[String]                                                                  | \[Number]\[String]\[Boolean] | Removes the specified key and its corresponding value from this map.Returns the previous value associated with the key, or `null` if the key was not present in the map.                                                                                              |
| `remove(Key, Value)`      | Key:\[String]Value:\[Number]\[String]\[Boolean] | \[Boolean]                           | Removes the entry for the specified key only if it is mapped to the specified value.Returns `true` if entry was removed                                                                                                                                               |
| `containsKey(Key)`        | \[String]                                                                  | \[Boolean]                           | Returns `true` if the map contains the specified key.                                                                                                                                                                                                                      |
| `containsValue(Value)`    | \[Number]\[String]\[Boolean]                                       | \[Boolean]                           | Returns `true` if the map has at least one key associated with the specified value.                                                                                                                                                                                        |
| `clear()`                 | -                                                                         | -                                   | Removes all of the mappings from this map                                                                                                                                                                                                                                  |

## DateTime { #datetime }

This data type represents date and time and allows to manipulate them.

### Properties { #properties }

| Property         | Type      | Description                      |
|:-----------------|:----------|:---------------------------------|
| `millis`         | \[Number]  | Milliseconds                     |
| `millisOfDay`    | \[Number]  | Millis of day                    |
| `millisOfSecond` | \[Number]  | Millis of second                 |
| `secondOfDay`    | \[Number]  | Second of day                    |
| `secondOfMinute` | \[Number]  | Second of minute                 |
| `minuteOfDay`    | \[Number]  | Minute of day                    |
| `minuteOfHour`   | \[Number]  | Minute of hour                   |
| `hourOfDay`      | \[Number]  | Hour of day                      |
| `dayOfMonth`     | \[Number]  | Day of month                     |
| `dayOfWeek`      | \[Number]  | Day of week                      |
| `dayOfYear`      | \[Number]  | Day of year                      |
| `weekOfWeekyear` | \[Number]  | Week of weekyear                 |
| `weekyear`       | \[Number]  | Week year \*                      |
| `monthOfYear`    | \[Number]  | Month of year                    |
| `year`           | \[Number]  | Year                             |
| `yearOfCentury`  | \[Number]  | Year of century                  |
| `yearOfEra`      | \[Number]  | Year of era                      |
| `centuryOfEra`   | \[Number]  | Century of era                   |
| `era`            | \[Number]  | Era                              |
| `zoneOffset`     | \[Number]  | Timezone offset in milliseconds  |
| `isAfterNow`     | \[Boolean] | `true` if this date is in future |
| `isBeforeNow`    | \[Boolean] | `true` if this date is in past   |

::: info \* Week year
Because the first day of the first week does not always fall on the first day of the year, sometimes the week-year will
differ from the month year.

For example, in the US, the week that contains Jan 1 is always the first week. In the US, weeks also start on Sunday.
If Jan 1 was a Monday, the Dec 31 would belong to the same week as Jan 1, and thus the same week-year as Jan 1.
Dec 30 would have a different week-year than Dec 31.
:::

### Methods { #methods }

The methods below do not modify the current instance, but return a new one.

| Method                 | Parameters | Returns    | Description                                                            |
|:-----------------------|:-----------|:-----------|:-----------------------------------------------------------------------|
| `plusMillis(Amount)`   | \[Number]   | \[DateTime] | Returns a copy of this datetime plus the specified number of millis.   |
| `plusSeconds(Amount)`  | \[Number]   | \[DateTime] | Returns a copy of this datetime plus the specified number of seconds.  |
| `plusMinutes(Amount)`  | \[Number]   | \[DateTime] | Returns a copy of this datetime plus the specified number of minutes.  |
| `plusHours(Amount)`    | \[Number]   | \[DateTime] | Returns a copy of this datetime plus the specified number of hours.    |
| `plusDays(Amount)`     | \[Number]   | \[DateTime] | Returns a copy of this datetime plus the specified number of days.     |
| `plusWeeks(Amount)`    | \[Number]   | \[DateTime] | Returns a copy of this datetime plus the specified number of weeks.    |
| `plusMonths(Amount)`   | \[Number]   | \[DateTime] | Returns a copy of this datetime plus the specified number of months    |
| `plusYears(Amount)`    | \[Number]   | \[DateTime] | Returns a copy of this datetime plus the specified number of years.    |
| `minusMillis(Amount)`  | \[Number]   | \[DateTime] | Returns a copy of this datetime minus the specified number of millis.  |
| `minusSeconds(Amount)` | \[Number]   | \[DateTime] | Returns a copy of this datetime minus the specified number of seconds. |
| `minusMinutes(Amount)` | \[Number]   | \[DateTime] | Returns a copy of this datetime minus the specified number of minutes. |
| `minusHours(Amount)`   | \[Number]   | \[DateTime] | Returns a copy of this datetime minus the specified number of hours.   |
| `minusDays(Amount)`    | \[Number]   | \[DateTime] | Returns a copy of this datetime minus the specified number of days.    |
| `minusWeeks(Amount)`   | \[Number]   | \[DateTime] | Returns a copy of this datetime minus the specified number of weeks.   |
| `minusMonths(Amount)`  | \[Number]   | \[DateTime] | Returns a copy of this datetime minus the specified number of months.  |
| `minusYears(Amount)`   | \[Number]   | \[DateTime] | Returns a copy of this datetime minus the specified number of years.   |
| `isAfter(Date)`        | \[DateTime] | \[Boolean]  | Is this date strictly after the specified date.                        |
| `isBefore(Date)`       | \[DateTime] | \[Boolean]  | Is this date strictly before the specified date.                       |
