# SERVER EXPORTS

<details>

<summary>Darkchat Conversation Structure</summary>

{% code overflow="wrap" %}

```
{
  "id": 1,
  "name": "Heist Planning",
  "appName": "darkchat",
  "createdBy": 5,
  "joinCode": "X9Z2A1",
  "createdAt": 1678900000,
  "updatedAt": 1678900000,
  "recipients": [],
  "messages": [],
  "isItRead": true
}
```

{% endcode %}

</details>

### Create Conversation (By Source)

Creates a new Darkchat conversation for a player using their Server ID (Source). You can optionally specify a join code.

{% code overflow="wrap" lineNumbers="true" %}

```lua
local result = exports["17mov_Phone"]:Darkchat_CreateConversationBySrc(src, name, joinCode)
```

{% endcode %}

**Returns:**

* `table`: `{ success: boolean, newConv?: DarkchatConversation }`

<table><thead><tr><th width="114" align="center">Argument</th><th width="97" align="center">Type</th><th width="110" align="center">Optional</th><th>Explanation</th></tr></thead><tbody><tr><td align="center">src</td><td align="center"><code>number</code></td><td align="center">❌</td><td>The player's server ID (source).</td></tr><tr><td align="center">name</td><td align="center"><code>string</code></td><td align="center">❌</td><td>The name of the conversation.</td></tr><tr><td align="center">joinCode</td><td align="center"><code>string</code></td><td align="center">✅</td><td>Code to join conversation. If not provided, it will be generated automatically.</td></tr></tbody></table>

### Create Conversation (By Number)

Creates a new Darkchat conversation for a player using their phone number.

<pre class="language-lua" data-overflow="wrap" data-line-numbers><code class="lang-lua"><strong>local result = exports["17mov_Phone"]:Darkchat_CreateConversationByNumber(number, name, joinCode)
</strong></code></pre>

**Returns:**

* `table`: `{ success: boolean, newConv?: DarkchatConversation }`

<table><thead><tr><th width="122" align="center">Argument</th><th width="103" align="center">Type</th><th width="114" align="center">Optional</th><th>Explanation</th></tr></thead><tbody><tr><td align="center">number</td><td align="center"><code>number</code></td><td align="center">❌</td><td>The player's phone number.</td></tr><tr><td align="center">name</td><td align="center"><code>string</code></td><td align="center">❌</td><td>The name of the conversation.</td></tr><tr><td align="center">joinCode</td><td align="center"><code>string</code></td><td align="center">✅</td><td>Code to join conversation. If not provided, it will be generated automatically.</td></tr></tbody></table>

### Add To Conversation (By Source)

Adds a player to an existing Darkchat conversation using their Server ID (Source).

{% code overflow="wrap" lineNumbers="true" %}

```lua
local success = exports["17mov_Phone"]:Darkchat_AddToConversationBySrc(src, conversationId)
```

{% endcode %}

**Returns:**

* `boolean`: `true` if the user was successfully added.

<table><thead><tr><th width="136" align="center">Argument</th><th width="95">Type</th><th width="111" align="center">Optional</th><th>Explanation</th></tr></thead><tbody><tr><td align="center">src</td><td><code>number</code></td><td align="center">❌</td><td>The player's server ID (source).</td></tr><tr><td align="center">conversationId</td><td><code>number</code></td><td align="center">❌</td><td>ID of the conversation to add the user to.</td></tr></tbody></table>

### Add To Conversation (By Number)

Adds a player to an existing Darkchat conversation using their phone number.

{% code overflow="wrap" lineNumbers="true" %}

```lua
local success = exports["17mov_Phone"]:Darkchat_AddToConversationByNumber(number, conversationId)
```

{% endcode %}

**Returns:**

* `boolean`: `true` if the user was successfully added.

<table><thead><tr><th width="136" align="center">Argument</th><th width="97" align="center">Type</th><th width="105" align="center">Optional</th><th>Explanation</th></tr></thead><tbody><tr><td align="center">number</td><td align="center"><code>number</code></td><td align="center">❌</td><td>The player's phone number.</td></tr><tr><td align="center">conversationId</td><td align="center"><code>number</code></td><td align="center">❌</td><td>ID of the conversation to add the user to.</td></tr></tbody></table>

### Remove From Conversation (By Source)

Removes a player from a Darkchat conversation using their Server ID (Source).

{% code overflow="wrap" lineNumbers="true" %}

```lua
local success = exports["17mov_Phone"]:Darkchat_RemoveFromConversationBySrc(src, conversationId, isSelf)
```

{% endcode %}

**Returns:**

* `boolean`: `true` if the user was successfully removed.

<table><thead><tr><th width="135" align="center">Argument</th><th width="82" align="center">Type</th><th width="107" align="center">Optional</th><th>Explanation</th></tr></thead><tbody><tr><td align="center">src</td><td align="center"><code>number</code></td><td align="center">❌</td><td>The player's server ID (source).</td></tr><tr><td align="center">conversationId</td><td align="center"><code>number</code></td><td align="center">❌</td><td>ID of the conversation to remove the user from.</td></tr></tbody></table>

### Remove From Conversation (By Number)

Removes a player from a Darkchat conversation using their phone number.

{% code overflow="wrap" lineNumbers="true" %}

```lua
local success = exports["17mov_Phone"]:Darkchat_RemoveFromConversationByNumber(number, conversationId, isSelf)
```

{% endcode %}

**Returns:**

* `boolean`: `true` if the user was successfully removed.

<table><thead><tr><th width="140" align="center">Argument</th><th width="96" align="center">Type</th><th width="117" align="center">Optional</th><th>Explanation</th></tr></thead><tbody><tr><td align="center">number</td><td align="center"><code>number</code></td><td align="center">❌</td><td>The player's phone number.</td></tr><tr><td align="center">conversationId</td><td align="center"><code>number</code></td><td align="center">❌</td><td>ID of the conversation to remove the user from.</td></tr></tbody></table>
