> ## Documentation Index
> Fetch the complete documentation index at: https://docs.haze.rest/llms.txt
> Use this file to discover all available pages before exploring further.

# Haze Scripting: Build Rich Discord Messages

> Turn plain text templates into fully styled Discord cards with variable interpolation, layout tags, media, and buttons — no code required.

Haze scripting lets you write a text template that haze compiles into a rich Discord card — complete with a title, body text, media, action buttons, and an accent color. You can keep things simple with variable placeholders like `{user.mention}`, or go further and add layout tags like `{title: …}` and `{color: haze}` to build a fully branded message without touching any code.

## Two Modes

The engine automatically picks a rendering mode based on what your template contains.

| Mode                 | When it applies                                    | What you get                                                                    |
| -------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------- |
| **Variables only**   | Template has no `{name: value}` tags               | Interpolated plain text — variables are replaced, everything else is left as-is |
| **Component script** | Template contains at least one `{name: value}` tag | A rich embedded card assembled from your tags — title, text, media, and buttons |

## How Detection Works

Haze scans your template for tags that follow the `{name: value}` pattern — a name, a colon, and a value. If at least one such tag is found, the whole template is treated as a component script. If none are found, it runs in variables-only mode and your text is returned with variables substituted.

A `{user.mention}` placeholder has no colon after the root word, so it is always treated as a variable, not a tag. The colon is what separates the two systems.

## Preview Commands

Before saving a script to a ticket welcome or any other setting, preview it in Discord so you can catch mistakes early.

Preview a script inline:

```bash theme={null}
,script preview {title: Hello {user.display_name}} {text: From **{guild.name}**}
```

List every variable available in the current context:

```bash theme={null}
,script vars
```

List every supported layout and media tag:

```bash theme={null}
,script tags
```

## Where Scripts Are Used

* **Ticket welcome messages** — set a server-wide default welcome that fires when any ticket is opened
* **Per-button welcome messages** — override the default for a specific ticket button so different buttons can show different cards

<Tip>
  Ready to go deeper? See [Tags](/scripting/tags) for the full layout, media, and button tag reference, and [Variables](/scripting/variables) for every available placeholder and its output.
</Tip>
