PlaceholdersParsers
Union Parser
The Union Parser returns one of two messages depending on whether any of the conditions you list is true.
The Union Parser tests a list of conditions and returns your first message as soon as one of them passes. Use the Logical Parser when every condition has to pass instead.
Usage
To use the parser, insert the following syntax in your text:
{union(expression|expression|...):trueMessage|falseMessage}
- You can also reference this parser using the aliases: any, or
Separate the conditions with a pipe. Each condition is written the same way as an If Parser condition, so ==, !=, >, <, >= and <= all work, and any placeholder available in that message can be used inside one.
Examples
- Matching any of several answers:
- Input:
{union({args.raw}==hi|{args.raw}==hello|{args.raw}==hey):Hello {member.displayName}!|I did not catch that.} - With
{args.raw}set tohello:Hello NotDemo! - With
{args.raw}set togood morning:I did not catch that.
- Either of two roles:
- Input:
{union({contains(111):{member.roles}}|{contains(222):{member.roles}}):Staff tools are open to you.|Ask a staff member for help.} - Output for a member holding either role:
Staff tools are open to you. - Output for everyone else:
Ask a staff member for help.
- Either end of a range:
- Input:
{union({guild.memberCount}<100|{guild.memberCount}>10000):Thanks for being here.|Welcome to the server.} - Output at 40 members:
Thanks for being here. - Output at 4000 members:
Welcome to the server.
- Nothing when no condition passes:
- Input:
{union({args.raw}==help|{args.raw}==support):Open a ticket with /new and a staff member will pick it up.} - Output when the member typed
helporsupport:Open a ticket with /new and a staff member will pick it up. - Output for anything else: nothing at all.
Available Parameters
| Parameter | Description | Default | Example |
|---|---|---|---|
| expression | A condition to test. Repeat it, separated by a pipe, to test several at once (required) | - | {args.raw}==hi |
| trueMessage | Returned when at least one condition passes (required) | - | Hello! |
| falseMessage | Returned when every condition fails | empty | No match. |
Notes
- Conditions are read from left to right and the true message is returned as soon as one of them passes.
- Comparisons are made on text, so
Yesandyesare different values. Run the value through the String Format Parser first if casing should be ignored. - A condition written as
trueorfalseis used as it stands, which is what makes parsers such ascontainswork inside one. - A condition with no comparison operator in it always counts as passing.
- Leave the pipe out of the payload and a failed test produces nothing.
- To use a pipe as ordinary text inside a message, write it as
\|.