# Commands

The Commands module provides a simple interface to register server commands with built-in permission checking and chat suggestions.

***

#### Accessing the Module

```lua
local COMMANDS <const> = exports.boii_utils:get("modules.commands")
```

***

## Server

### register\_command(command, required\_rank, help, params, handler)

Registers a new server command.

#### **Parameters**

| Name           | Type       | Description                                                                           |
| -------------- | ---------- | ------------------------------------------------------------------------------------- |
| command        | `string`   | The command name to register (e.g., `"/kick"`).                                       |
| required\_rank | \`string   | table\`                                                                               |
| help           | `string`   | Help text for the command (displayed in suggestions).                                 |
| params         | `table`    | Array of parameter objects with `name` and `help` fields.                             |
| handler        | `function` | Function to execute when the command is run. Signature: `function(source, args, raw)` |

#### **Example**

```lua
COMMANDS.register("announce", "admin", "Broadcast a message to all players", {
    { name = "message", help = "The message to broadcast" }
}, function(source, args, raw)
    local message = table.concat(args, " ")
    TriggerClientEvent("chat:addMessage", -1, {
        args = { "^3Announcement", message }
    })
end)
```

***

## Client

### get\_chat\_suggestions()

Requests the server to send updated chat suggestions to the client.

#### **Parameters**

| Name | Type | Description                        |
| ---- | ---- | ---------------------------------- |
| None | -    | This function takes no parameters. |

#### **Example**

```lua
COMMANDS.get_chat_suggestions()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.boii.dev/old-docs/boii_utils/api/commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
