> For the complete documentation index, see [llms.txt](https://dbd-ts.gitbook.io/dbdts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dbd-ts.gitbook.io/dbdts/guides/custom-functions.md).

# Custom Functions

DBD.TS allows you to create your own custom functions! ✨

Custom functions can be used as a way to condense and optimize codes.

#### Creating a Custom Function

**Template:**

```javascript
bot.createCustomFunction({
    name: "name", //The name of this custom function
    code: `code` //The code to execute when the function is called
})
```

**Example:**

```javascript
bot.createCustomFunction({
    name: "userdata",
    code: `$textSplit[$userTag&&$authorID&&$authorAvatar;&&]`
})
```

#### Using Custom Functions

Custom functions called using `$callFunction[]`.

**Example:**

```javascript
bot.command({
    type: "basicCommand",
    name: "example",
    code: `$callFunction[userdata]
Tag: $splitText[1]
ID: $splitText[2]
Avatar: <$splitText[3]>`
})
```
