> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-staff-chat/configuration.md).

# Configuration

CAS Staff Chat configuration: command or key, admin list, clear permission, alert command, name and avatar sources, Discord bot token and language.

## `config.lua`

```lua
CAS = {
    UseSteamName = true,
    EnableCommand = true,
    keyHash = 0xF3830D8E,
    Command = "staffchat",
    toggleNotifyCircle = "togglebox",
    clearChatHistoryCommand = "clearchat",
    Language = "en",
}
```

| Option                    | Default          | What it does                                                                                                          |
| ------------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------- |
| `UseSteamName`            | `true`           | Shows the admin's Steam name when Discord names are off. With `false`, the character's first and last name are shown. |
| `EnableCommand`           | `true`           | `true` opens the chat with the command. `false` opens it with the key in `keyHash`.                                   |
| `keyHash`                 | `0xF3830D8E` (J) | The key that opens the chat when `EnableCommand` is `false`.                                                          |
| `Command`                 | `"staffchat"`    | Command that opens the chat.                                                                                          |
| `toggleNotifyCircle`      | `"togglebox"`    | Command that switches the new-message alerts on or off.                                                               |
| `clearChatHistoryCommand` | `"clearchat"`    | Command that clears the history.                                                                                      |
| `Language`                | `"en"`           | Language of the messages, from `locales.lua`.                                                                         |

### Admins

```lua
CAS.Admins = {
    ["steam:110000100000000"] = {
        canClearChatHistory = true
    },
}
```

Each key is an admin's Steam hex in lower case. `canClearChatHistory` lets that admin use the clear command. Everyone listed here can open, read and write in the chat.

## `server_config.lua`

```lua
Config = {
    UseDiscordAvatar = true,
    UseDiscordName   = true,
    DiscordBotToken  = "",
}
```

| Option             | What it does                                                                                                                   |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `UseDiscordAvatar` | `true` shows the admin's Discord avatar. `false` shows their Steam avatar.                                                     |
| `UseDiscordName`   | `true` shows the admin's Discord username. `false` falls back to `UseSteamName`.                                               |
| `DiscordBotToken`  | The bot token used to read Discord profiles. See [Discord Profiles](/script-documentation/cas-staff-chat/discord-profiles.md). |

`server_config.lua` is only loaded on the server, so the token is never sent to players.

## Which name and avatar are shown

| Name             | Used when                                          |
| ---------------- | -------------------------------------------------- |
| Discord username | `UseDiscordName = true`                            |
| Steam name       | `UseDiscordName = false` and `UseSteamName = true` |
| Character name   | Both are `false`                                   |

| Avatar         | Used when                  |
| -------------- | -------------------------- |
| Discord avatar | `UseDiscordAvatar = true`  |
| Steam avatar   | `UseDiscordAvatar = false` |

Avatars and names are loaded when an admin joins and kept for the session.

## Language

`locales.lua` holds the texts under `Languages["en"]`. To translate them, copy the block, give it a new code, translate the values and set `CAS.Language` to that code.
