> ## 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.

# Scripting Variables: Placeholders and Live Context

> Complete reference for every variable placeholder available in haze scripts — user, guild, channel, ticket, and button context fields.

Variables let you inject live context into your script templates — the name of the user who opened a ticket, the guild's icon URL, the current channel mention, and more. Every variable resolves at render time, so the output always reflects the actual values from the Discord context in which the script runs.

<Note>
  Variables use a **dot** to separate parts and **no colon** — write `{user.name}`, not `{user: name}`. A colon turns something into a layout tag, which is a different system entirely. To print a literal brace without triggering variable resolution, escape it with a backslash: `\{not_a_var\}`.
</Note>

## Available Roots

Each root maps to a source object that haze resolves from the current context.

| Root                   | Source                                                          |
| ---------------------- | --------------------------------------------------------------- |
| `user`                 | The invoker or ticket opener (Discord Member)                   |
| `guild`                | The current server                                              |
| `channel`              | The current channel (when available)                            |
| `ticket` / `ticket_id` | The open ticket ID (tickets only)                               |
| `button` / `button_id` | The button label or ID that triggered the script (tickets only) |

**Aliases:** `author` and `member` both resolve to `user`. `server` resolves to `guild`. You can use whichever reads most naturally in your template.

## User Variables

| Variable                  | Output                                              |
| ------------------------- | --------------------------------------------------- |
| `{user}`                  | Display string (nick or username)                   |
| `{user.mention}`          | `<@id>` — pings the user                            |
| `{user.name}`             | Username (without discriminator)                    |
| `{user.display_name}`     | Server nickname if set, otherwise username          |
| `{user.id}`               | Snowflake ID                                        |
| `{user.avatar}`           | Avatar URL (usable in `{thumbnail: …}`)             |
| `{user.bot}`              | `true` or `false`                                   |
| `{user.joined_at}`        | Unix timestamp of when the user joined the server   |
| `{user.top_role}`         | Name of the user's highest role                     |
| `{user.top_role.mention}` | Role mention (`<@&id>`) for the user's highest role |

## Guild Variables

| Variable               | Output                                |
| ---------------------- | ------------------------------------- |
| `{guild}`              | Server name                           |
| `{guild.name}`         | Server name                           |
| `{guild.id}`           | Snowflake ID                          |
| `{guild.icon}`         | Server icon URL                       |
| `{guild.member_count}` | Formatted member count (e.g. `1,234`) |

## Channel Variables

| Variable            | Output                             |
| ------------------- | ---------------------------------- |
| `{channel}`         | Channel name (without `#`)         |
| `{channel.mention}` | `<#id>` — a clickable channel link |
| `{channel.id}`      | Snowflake ID                       |

## Ticket & Button Variables

These variables are only available when a script is rendered inside a ticket context.

| Variable                   | Output                                                      |
| -------------------------- | ----------------------------------------------------------- |
| `{ticket}` / `{ticket_id}` | The ID of the currently open ticket                         |
| `{button}` / `{button_id}` | The label or custom ID of the button that opened the ticket |

## Inspect Live Variables

To see every variable key that is available in your current Discord context, run:

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

This prints a live list of all resolvable paths — useful when you want to confirm a variable exists before writing your script.
