PlaceholdersParsers
Includes Parser for Placeholders
Check whether a list or a piece of text contains a value in a Tickety placeholder, with array membership, string matches, number matching and examples.
Usage
To use the parser, insert the following syntax in your text:
{includes(<search>):<payload>}
Aliases: in, contains, contain - all behave the same way.
Behaviour
- If the payload is a JSON array (e.g.
["a","b"]), the parser checks whether any element strictly matches the search value after coercing array elements to strings. This means numeric array elements like63will match the search value"63". - If the payload is not valid JSON, the parser falls back to a substring check using
String.prototype.includeson the payload string.
Examples
1. Array membership (JSON array payload)
- Input:
{includes(apple):["apple","banana"]} - Output:
true
2. String contains (plain string payload)
- Input:
{includes(world):Hello world} - Output:
true
3. Numeric match with type coercion
- Input:
{includes(63):[63,72,81]} - Output:
true
4. Using placeholders
- Input:
{includes(123):{member.roles}} - Assuming
member.rolesis"[\"123\",\"456\"]"(a JSON array string) - Output:
true
Notes
- When given a JSON array payload, elements are compared by converting each element to a string and doing a strict string equality check against the search value.
- When the payload is not a JSON array, a substring
includescheck is performed on the payload string. - Whitespace around the search parameter is trimmed before comparison.
If Parser
Return one message or another in a Tickety placeholder based on a comparison between two values, with the expression operators, examples and notes.
Join Parser
Combine the items of a list into one string with a separator in a Tickety placeholder, with formatting for user, role and channel mentions and examples.