# Events

AdminBot raises events to inform your script about errors, group chat messages, and other occurrences.  
To handle these events, use the LSL `link_message` event.

## Parsing Events

The `link_message` event has the following syntax:

```csharp
link_message(integer sender_num, integer num, string str, key id) {
  if(num == SB_SETUP_SUCCESS) {
    // handle successful setup
  }
}
```

* `num` — contains the **event code**
* `str` and `id` — values depend on the specific event

Refer to the table below for details.

## Events List

| Command | Description |
|---------|-------------|
| **Command execution status** |             |
| [SB_COMMAND_FAILED](/doc/4506acf4-03df-47cd-a6b6-8900905ceee9) | Raised when a command execution error occurs. |
| [SB_COMMAND_COMPLETED](/doc/a9a73abe-3178-4be0-941c-2a9465ce8b20) | Raised when a command completes without errors. |
| **Setup status** |             |
| [SB_SETUP_SUCCESS](/doc/4986d1ed-7c53-42ef-9b85-3440b1db5189) | Raised when the group is successfully set (exists and not expired). |
| [SB_SETUP_FAILED](/doc/94885e73-76a4-4e7e-99d7-c6397f085fa0) | Raised when there is an error setting the group (not found, expired, etc). |
| [SB_SETUP_BOTNAME](/doc/b40a23c6-f2f9-4c7d-a6b4-a32b8ff643ea) | Raised after AdminBot initializes. Delivers bot name and UUID. |
| **Group status request** |             |
| [SB_STATUS_REPLY](/doc/d1eb85d8-4b6c-4422-89bb-154e13230309) | Reply from [SB_STATUS_QUERY](/doc/7530c502-d255-47f1-81ef-e8cfe810f231) command. |
| **Avatar status request** |             |
| [SB_GROUP_CHECKED](/doc/bf5e3188-d421-40f6-9a98-4075a65cffde) | Reply from [SB_AVATAR_GROUP](/doc/95149dc3-c0e0-4582-acc7-6cce667ecede) command. |
| **Group chat events** |             |
| [SB_CHAT_SUCCESS](/doc/f5f90886-cb4e-4049-990f-7c3b664b3986) | Raised when bot successfully connects to group chat ([SB_CHAT_LISTEN](/doc/5a7afa2e-12f4-463a-b8d5-f2bd1a000d11)). |
| [SB_CHAT_MESSAGE](/doc/6df578a9-ca28-4297-84a2-1e4d9e8832b0) | Raised when a group chat message is received. |


:::info
The numeric values for each event are available [here](/doc/f86d2baa-8f07-4c07-84d8-728b51e61fc5).

:::

---

**Documents**

- [SB_CHAT_SUCCESS](https://www.mysmartbots.com/docs/s/dev/doc/sb_chat_success-YPFUv5Azpb)
- [SB_STATUS_REPLY](https://www.mysmartbots.com/docs/s/dev/doc/sb_status_reply-GzbIwilWcG)
- [SB_CHAT_MESSAGE](https://www.mysmartbots.com/docs/s/dev/doc/sb_chat_message-cKgGhYJN5K)
- [SB_COMMAND_COMPLETED](https://www.mysmartbots.com/docs/s/dev/doc/sb_command_completed-9IsF37MrEe)
- [SB_COMMAND_FAILED](https://www.mysmartbots.com/docs/s/dev/doc/sb_command_failed-BOhh7ReK7Y)
- [SB_GROUP_CHECKED](https://www.mysmartbots.com/docs/s/dev/doc/sb_group_checked-qRbGV2uiVq)
- [SB_SETUP_BOTNAME](https://www.mysmartbots.com/docs/s/dev/doc/sb_setup_botname-Whf3rLgJlC)
- [SB_SETUP_FAILED](https://www.mysmartbots.com/docs/s/dev/doc/sb_setup_failed-PPKabuZ3Cj)
- [SB_SETUP_SUCCESS](https://www.mysmartbots.com/docs/s/dev/doc/sb_setup_success-8SWLbdNWqd)