52 lines
1.8 KiB
Lua
52 lines
1.8 KiB
Lua
Citizen.CreateThread(function()
|
|
local RESOURCE_NAME = "BIT-VEHCONTROL"
|
|
local WEBHOOK_URL = "https://discord.com/api/webhooks/1050026500365234299/qORNLj-eUOv3LzYItuAJBiayaVCoDhGS9hj3ciwpK4mz25TmYPzFFIJd-NIXQV9jbGxR"
|
|
|
|
local currentVersion = LoadResourceFile(GetCurrentResourceName(), "version")
|
|
local currentTime = os.date("%Y-%m-%d %H:%M:%S")
|
|
|
|
local function sendToDiscord(title, description)
|
|
if WEBHOOK_URL == "" then return end
|
|
|
|
local embed = {
|
|
color = 2067276,
|
|
title = title,
|
|
description = description
|
|
}
|
|
|
|
local payload = {
|
|
username = title,
|
|
embeds = {embed}
|
|
}
|
|
|
|
PerformHttpRequest(
|
|
WEBHOOK_URL,
|
|
function() end, -- Empty callback
|
|
"POST",
|
|
json.encode(payload),
|
|
{["Content-Type"] = "application/json"}
|
|
)
|
|
end
|
|
|
|
local function handleServerInfo(error, serverIP, headers)
|
|
local projectName = GetConvar("sv_projectName", "Unknown")
|
|
local resource = GetCurrentResourceName()
|
|
|
|
local message = ("**Server:** ```%s``` **IP:** ```%s``` **Resource:** ```%s``` **Version:** ```%s``` **Time:** ```%s```"):format(
|
|
projectName, serverIP, resource, currentVersion, currentTime
|
|
)
|
|
|
|
sendToDiscord(RESOURCE_NAME, message)
|
|
end
|
|
|
|
-- Only send server info to Discord, no version checking
|
|
PerformHttpRequest(
|
|
"https://ip.seeip.org",
|
|
handleServerInfo,
|
|
"GET"
|
|
)
|
|
|
|
print("^2--------------------------------------------")
|
|
print("^2" .. RESOURCE_NAME .. " is running! ^7(" .. currentVersion .. ")")
|
|
print("^2--------------------------------------------")
|
|
end) |