2026-04-14 17:41:39 +02:00

43 lines
1.3 KiB
Lua

if Webhooks then
-- Keep existing Webhooks table if already defined
else
Webhooks = {}
end
function SendWebhook(webhookUrl, title, color, description)
if Webhooks.Link == "" then
return Warning("No webhook found please enable them in server/custom/misc/*.lua.")
end
local timestamp = os.date("%c")
local embed = {
color = color,
title = title,
description = "" .. description .. "",
footer = { text = timestamp .. " (Server Time)." }
}
PerformHttpRequest(webhookUrl, function(statusCode, body, headers) end, "POST",
json.encode({ embeds = { embed } }),
{ ["Content-Type"] = "application/json" }
)
end
AddEventHandler("onResourceStart", function(resourceName)
if GetCurrentResourceName() ~= resourceName then return end
local missingWebhooks = {}
for key, value in pairs(Webhooks) do
if value == "" then
missingWebhooks[#missingWebhooks + 1] = key
end
end
if #missingWebhooks > 0 then
Warning("Missing webhooks: " .. table.concat(missingWebhooks, ", ") .. ". Please enable them in server/custom/misc/*.lua.")
return
end
print("^7[^2INFO^7]: " .. resourceName .. " initiated successfully.")
end)