mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 17:58:54 +00:00
feat(es_extended): Discord Logs
adds: - ` ESX.DiscordLog` - `ESX.DiscordLogFields`
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user