# $colorRole

The `$colorRole` function **changes the color** of the first role mentioned in the command message. It does not return anything.

## Syntax

```
$colorRole[color;(reason)]
```

## Parameters

| Parameter | Description |
|---|---|
| `color` | Required. The new color, as hex (`#5865F2`, or hex digits when the value contains a letter `a`-`f`) or as a decimal number between 0 and 16777215. A value made only of digits without `#` is read as decimal (`123456` is the number 123456, not hex). An invalid color raises `Invalid role color.` |
| `reason` | Optional. Reason recorded in the server's audit log (up to 512 characters). Empty, or absent, uses the reason set with `$auditLogReason`, if any. |

## Return value

| Type | Description |
|---|---|
| `string` | An empty string. The color of the role is modified. |

The new color replaces all the colors of the role: a gradient or holographic role becomes single-color. Use `$setRoleColors` for several colors.

## Examples

### Change the color of a role

```bdfd
$colorRole[#E74C3C]
$sendMessage[The role color has been changed.]
```

### Color given by the user

```bdfd
$colorRole[$message[2]]
$sendMessage[Color updated.]
```
Usage: `!color @Role #3498DB`

## Notes

- The role to modify is the first role mentioned in the message. If no role is mentioned, the function raises `Missing or invalid role ID.`
- To read the color of a role, use `$getRoleColor`; to change several properties at once, use `$modifyRole`.

## Audit log reason

The last, optional argument `reason` is the reason shown next to this action in the server's audit log (Discord's `X-Audit-Log-Reason`). Without it, the reason set earlier in the script with `$auditLogReason` is used; with neither, no reason is recorded.
