feat(es_extended): Discord Logs

adds:
- ` ESX.DiscordLog`
- `ESX.DiscordLogFields`
This commit is contained in:
Mycroft
2022-09-21 18:26:31 +01:00
parent c7cd3c529f
commit bf76cd9729
3 changed files with 71 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
Config.DiscordLogs = {
Webhooks = {
default = '',
test = '',
Chat = '',
UserActions = '',
Resources = ''
},
Colors = { -- https://www.spycolor.com/
default = 14423100,
blue = 255,
red = 16711680,
green = 65280,
white = 16777215,
black = 0,
orange = 16744192,
yellow = 16776960,
pink = 16761035,
lightgreen = 65309
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ shared_scripts {
server_scripts {
'@oxmysql/lib/MySQL.lua',
'config.logs.lua',
'server/common.lua',
'server/classes/player.lua',
'server/classes/overrides/*.lua',
+48
View File
@@ -265,6 +265,54 @@ function ESX.GetIdentifier(playerId)
end
end
function ESX.DiscordLog(name, title, color, message)
local webHook = Config.DiscordLogs.Webhooks[name] or Config.DiscordLogs.Webhooks.default
local embedData = {{
['title'] = title,
['color'] = Config.DiscordLogs.Colors[color] or Config.DiscordLogs.Colors.default,
['footer'] = {
['text'] = "| ESX Logs | " .. os.date(),
['icon_url'] = "https://cdn.discordapp.com/attachments/944789399852417096/1020099828266586193/blanc-800x800.png"
},
['description'] = message,
['author'] = {
['name'] = "ESX Framework",
['icon_url'] = "https://cdn.discordapp.com/emojis/939245183621558362.webp?size=128&quality=lossless"
}
}}
PerformHttpRequest(webHook, nil, 'POST', json.encode({
username = 'Logs',
embeds = embedData
}), {
['Content-Type'] = 'application/json'
})
end
function ESX.DiscordLogFields(name, title, color, fields)
local webHook = Config.DiscordLogs.Webhooks[name] or Config.DiscordLogs.Webhooks.default
local embedData = {{
['title'] = title,
['color'] = Config.DiscordLogs.Colors[color] or Config.DiscordLogs.Colors.default,
['footer'] = {
['text'] = "| ESX Logs | " .. os.date(),
['icon_url'] = "https://cdn.discordapp.com/attachments/944789399852417096/1020099828266586193/blanc-800x800.png"
},
['fields'] = fields,
['description'] = "",
['author'] = {
['name'] = "ESX Framework",
['icon_url'] = "https://cdn.discordapp.com/emojis/939245183621558362.webp?size=128&quality=lossless"
}
}}
PerformHttpRequest(webHook, nil, 'POST', json.encode({
username = 'Logs',
embeds = embedData
}), {
['Content-Type'] = 'application/json'
})
end
function ESX.RefreshJobs()
local Jobs = {}
local jobs = MySQL.query.await('SELECT * FROM jobs')