Skip to content
This repository was archived by the owner on Oct 1, 2023. It is now read-only.

Commit 7ae1494

Browse files
Isigargitbook-bot
authored andcommitted
GitBook: [master] 2 pages modified
1 parent a6efdd5 commit 7ae1494

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [Command system](natives/command-system.md)
1919
* [Camera API](natives/camera-api.md)
2020
* [Blips](natives/blips.md)
21+
* [Discord sender](natives/discord-sender.md)
2122

2223
## Our links
2324

natives/discord-sender.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
description: Send discord message via webhook
3+
---
4+
5+
# Discord sender
6+
7+
rcore has even discord implementation, so you can simply send discord notification via webhook to any of your room.
8+
9+
{% hint style="warning" %}
10+
Webhook has to be only visible for server! If it will be visible for client as well it can be stolen and someone make spam your rooms.
11+
{% endhint %}
12+
13+
### Sending notification as rcore
14+
15+
rcore has sconfig that mean Server Config so it is visible only for server in this config you can find DiscordWebhook field, if you want to send message into this webhook only you can use method
16+
17+
{% code title="your\_serverside.lua" %}
18+
```lua
19+
rcore = exports.rcore
20+
rcore:sendDiscordMessage(title, message, color, footer)
21+
```
22+
{% endcode %}
23+
24+
### Sending custom notification
25+
26+
other way if you want to send discord to any webhook for example in your own script you can use very similar native to it.
27+
28+
{% code title="your\_serverside.lua" %}
29+
```lua
30+
rcore = exports.rcore
31+
rcore:sendCustomDiscordMessage(webhook, title, message, color, footer)
32+
```
33+
{% endcode %}
34+
35+
### Example of sending join notification
36+
37+
{% code title="your\_serverside.lua" %}
38+
```lua
39+
rcore = exports.rcore
40+
41+
AddEventHandler('esx:playerLoaded', function(source)
42+
local xPlayer = ESX.GetPlayerFromId(source)
43+
if xPlayer then
44+
local webhook = ''
45+
local title = 'Player joined!'
46+
local message = string.format('Player %s has joined!', xPlayer.getName())
47+
local rcoreConfig = rcore:getConfig()
48+
local footer = 'cool script'
49+
50+
rcore:sendCustomDiscordNotification(webhook, title, message, rcoreConfig.DiscordColors.Green, footer)
51+
end
52+
53+
end)
54+
```
55+
{% endcode %}
56+
57+
### Colors
58+
59+
rcore has already table in config with colors, for more search for discord documentation
60+
61+
{% code title="rcore/config.lua" %}
62+
```lua
63+
Config.DiscordColors = {
64+
['Green'] = 56108,
65+
['Grey'] = 8421504,
66+
['Red'] = 16711680,
67+
['Orange'] = 16744192,
68+
['Blue'] = 2061822,
69+
['Purple'] = 11750815
70+
}
71+
```
72+
{% endcode %}
73+

0 commit comments

Comments
 (0)