# API

The client has a work-in-progress API that I've just begun creating, and here's the documentation for the existing functions.

![](https://3537671409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRUmEhzDEHjjqUvIxduhG%2Fuploads%2F9JOCEGWE1oMhehBzLCf7%2Fimage.png?alt=media\&token=d896d308-49dc-4166-b331-cda206516f23)

To make a plugin for the client, simply insert a return function into a module and place the module in the 'Plugins' folder.

```lua
return function(api)
    --> client api :)
end
```

### :getTopbarButton()

This method returns the Topbar+ button [(docs here)](https://1foreverhd.github.io/TopbarPlus/api/icon/) used to open the settings menu.

```lua
api:getTopbarButton():setRight()
```

![](https://3537671409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRUmEhzDEHjjqUvIxduhG%2Fuploads%2FIVAj8LjHxv5QZLqzG1F7%2Fimage.png?alt=media\&token=e9e9df8a-dd31-4169-8105-1cb68faecea1)

### :getSetting(\<container>,\<settingName>)

| UI                                | BubbleChat                                       |
| --------------------------------- | ------------------------------------------------ |
| Resizable \<boolean>              | Enabled \<boolean>                               |
| Roundness \<number/slider> (0-12) | AnimationStyle \<string> (Enum.EasingStyle list) |
| TextSize \<number/slider> (10-20) | FadeoutTime \<number/slider> (3-25)              |
|                                   | Font \<string> (Enum.Font list)                  |

For developers who want to create their own settings UI, they can use this method to access the values and change them accordingly'.

{% tabs %}
{% tab title="boolean" %}
A boolean value setting would look like this:

```lua
{
    value = true,
    type = "boolean",
    changed = <signal> --> (:Connect)
    set = <function>
}
```

### :set(\<boolean>)

Call the :set() function with the boolean value to update it's state.&#x20;

Example:

```lua
local setting = api:getSetting("UI","Resizable")
setting.changed:Connect(function(new)
    print(new)
end)
setting:set(false) --> disable resizable UI
```

{% endtab %}

{% tab title="string" %}
A string value setting would look like this:

```lua
{
    value = "Text",
    type = "string",
    options = {...},
    changed = <signal>,
    set = <function>
}
```

### :set(\<string>)

Call the :set() function with one of the values from the options table to update the setting.

```lua
local setting = api:getSetting("BubbleChat","Font")
local randomFont = setting.options[math.random(1,#setting.options)]
setting:set(randomFont)
```

{% endtab %}

{% tab title="number" %}
A number value setting would look like this:

```lua
{
    value = 16,
    limits = {10,20},
    type = "number",
    changed = <signal>,
    set = <function>
}
```

### :set(\<number>)

Call the :set() function with a number within the limits to update the value.

```lua
local setting = api:getSetting("UI","TextSize")
setting:set(16) --> set txt size to 16
```

{% endtab %}
{% endtabs %}

### :systemMessage(\<text>)

This method displays a system message in the chat with the specified text.

```lua
api:systemMessage("What?")
```

![](https://3537671409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRUmEhzDEHjjqUvIxduhG%2Fuploads%2F6VOCh4OmeXAs9OE7OVpB%2Fimage.png?alt=media\&token=1e387d2d-ccff-4b73-b436-a02b19dac7da)

### :getQuickChatSlot(\<number>)

If quick chat is enabled, you can pass a number from 1-20 to get the text in that specified quick chat slot.

```lua
api:getQuickChatSlot(1) --> nil/string
```

### :saveToQuickChatSlot(\<number>,\<string>)

If quick chat is enabled, you can pass both a number and the text you want to save to the specified quick chat slot to be used later.

```lua
api:saveToQuickChatSlot(1,"hi")
-- now saying /1 in chat will send 'hi'
```
