# Custom Commands

#### Registering a Command

The following script demonstrates how to register a basic Discord command using the provided `ExampleCommand` configuration:

```lua
local ExampleCommand = {
    name = "test",
    description = "This is the Test Description",
    access_roles = { "1111111111111111111", "2222222222222222222" }, -- DISCORD ROLE ID
    options = {
        {
            name = "id",
            description = "Provide an ID",
            optiontype = "number",
            required = true,
        },
        {
            name = "user",
            description = "Provide a User",
            optiontype = "user",
            required = true,
        },
        {
            name = "choice",
            description = "Select an Option",
            optiontype = "string",
            required = true,
            choices = {
                { name = "Option 1", value = "option1" },
                { name = "Option 2", value = "option2" },
            },
        }
    },
    onUse = function(args)
        args.reply({
            author = "Discord Bot",
            description = "First Argument: " .. args.id .. "\nInvoker: " .. args.user.username .. "\nSelected Option: " .. args.choice,
            color = "Green"
        })
        args.sendTo("user", { -- Argument Name (in this case 2nd option)
            author = "Discord Bot",
            description = "Hello!",
            color = "Green"
        })
    end,
}

TriggerEvent("upikk_discordbot:RegisterCommand", ExampleCommand)
```

#### Key Points

* **name**: Assigns a name to the command.
* **description**: Provides a brief about what the command does.
* **access\_roles**: Specifies the Discord roles that have access to this command.
* **options?**: Defines the required


---

# 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://upik.gitbook.io/scripts/discord-bot/custom-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.
