# Union Parser (/placeholders/parsers/union)



The Union Parser tests a list of conditions and returns your first message as soon as one of them passes. Use the [Logical Parser](/placeholders/parsers/logical) when every condition has to pass instead.

## Usage [#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](/placeholders/parsers/ifStatements) condition, so `==`, `!=`, `>`, `<`, `>=` and `<=` all work, and any placeholder available in that message can be used inside one.

## Examples [#examples]

1. 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 to `hello`: `Hello NotDemo!`
* With `{args.raw}` set to `good morning`: `I did not catch that.`

2. 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.`

3. 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.`

4. 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 `help` or `support`: `Open a ticket with /new and a staff member will pick it up.`
* Output for anything else: nothing at all.

## Available Parameters [#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 [#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 `Yes` and `yes` are different values. Run the value through the [String Format Parser](/placeholders/parsers/stringFormat) first if casing should be ignored.
* A condition written as `true` or `false` is used as it stands, which is what makes parsers such as `contains` work 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 `\|`.
