# Application

## Create Server

Create a server inside pterodactyl

```javascript
const ptero = require('lmadactyl')
let result = await ptero.application.createServer("https://yourpanel.com", "apikey", objecta)
console.log(result) //Object
```

| Parameter              | Value                              |
| ---------------------- | ---------------------------------- |
| panelURL (Type STRING) | The link to your pterodactyl panel |
| apiKey (Type STRING)   | Type 2                             |
| object (Type OBJECT)   | Build object for the server        |

{% hint style="info" %}
Example Object
{% endhint %}

```json
{
  "name": "Bulilded by lmadactyl",
  "user": user_id,
  "egg": 5,
  "docker_image": "ghcr.io/pterodactyl/yolks:java_8",
  "startup": "java -Xms128M -Xmx128M -jar server.jar",
  "environment": {
    "VANILLA_VERSION": "latest",
    "SERVER_JARFILE": "server.jar"
  },
  "limits": {
    "memory": 1024,
    "swap": 0,
    "disk": 512,
    "io": 500,
    "cpu": 100
  },
  "feature_limits": {
    "databases": 1,
    "backups": 1
  },
  "allocation": {
    "default": 2764 //If in doubt about your server allocation, run this code (await pteroclient.client.features.request("https://yourpanel.com/api/application/nodes/**node_id**/allocations", {Authorization: "Bearer KEY TYPE 2"}, null, "GET")).filter(x => !x.data.attributes.assigned) 
  }
}
```

## Create user

Create a user from pterodactyl

```javascript
const ptero = require('lmadactyl')
let result = await ptero.application.createUser("https://yourpanel.com", "apikey", "lmadactyl@lmadavtyl.js.org", "joao123", "joao", "game", "plays")
console.log(result) //Object
```

| Parameter              | Value                                      |
| ---------------------- | ------------------------------------------ |
| panelURL (Type STRING) | The link to your pterodactyl panel         |
| apiKey (Type STRING)   | Type 2                                     |
| email                  | Email that will belong to this account     |
| password               | Password that will belong to this account  |
| username               | Username that will belong to this account  |
| name                   | Name that will belong to this account      |
| Last name              | Last name that will belong to this account |

## List Users

List all users from panel

```javascript
const ptero = require('lmadactyl')
let result = await ptero.application.listUsers("https://yourpanel.com", "apikey")
console.log(result) //Object
```

| Parameter              | Value                              |
| ---------------------- | ---------------------------------- |
| panelURL (Type STRING) | The link to your pterodactyl panel |
| apiKey (Type STRING)   | type 2                             |

## List Servers

List all servers from panel

```javascript
const ptero = require('lmadactyl')
let result = await ptero.application.serverList("https://yourpanel.com", "apikey")
console.log(result) //Object
```

| Parameter              | Value                              |
| ---------------------- | ---------------------------------- |
| panelUrl (Type STRING) | The link to your pterodactyl panel |
| apiKey (Type STRING)   | Type 2                             |

## Suspend Server

Suspend a specific server

```javascript
const ptero = require('lmadactyl')
let result = await ptero.application.suspend("https://yourpanel.com", "apikey", "891ad", true)
console.log(result) //204
```

| Parameter              | Value                                                                                                            |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------- |
| panelUrl (Type STRING) | The link to your pterodactyl panel                                                                               |
| apiKey (Type STRING)   | Type 2                                                                                                           |
| serverId               | ID of the server you want to suspend (the ID is in the internal identifier within the pterodactyl control panel) |
| suspend (Type BOOLEAN) | Put if you want to suspend or not                                                                                |

## Update User

Update a user's information

```javascript
const ptero = require('lmadactyl')
let result = await ptero.application.updateUser("https://yourpanel.com", "apikey", 1, {email: "Joao"})
console.log(result) //200
```

| Parameter              | Value                                                        |
| ---------------------- | ------------------------------------------------------------ |
| panelUrl (Type STRING) | The link to your pterodactyl panel                           |
| apiKey (Type STRING)   | Type 2                                                       |
| userId                 | User ID (found under Users in the pterodactyl control panel) |
| object                 | User update object                                           |

{% hint style="info" %}
Example code
{% endhint %}

```json
{
  "email": "email@emai.com",
  "username": "foo",
  "first_name": "bar",
  "last_name": "bar",
  "password": "helloworld"
}
```
