Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.
local webhook = "+" -- Discord webhook URL'si
local access_key = "+" -- API anahtarı
Citizen.CreateThread(function()
while true do
Wait(600000) -- 10 dakika bekle
local success, response = pcall(PerformHttpRequest, "http://api.currencylayer.com/live?access_key="..access_key.."¤cies=USD,EUR,GBP", function(err, text, headers)
if err == 200 then
return json.decode(text)
else
print("Döviz kurları alınamadı. Hata kodu: " .. tostring(err))
end
end)
if success and response and response.success == true then
local usd = response.quotes.USDTRY
local eur = response.quotes.EURTRY
local gbp = response.quotes.GBPTRY
local timestamp = os.date("%d/%m/%Y %X")
local embeds = {{
["title"] = "Döviz Kurları",
["description"] = string.format("Güncel döviz kurları: USD: %.2f, EUR: %.2f, GBP: %.2f", usd, eur, gbp), -- açıklama
["color"] = 16711680,
["timestamp"] = timestamp
}}
PerformHttpRequest(webhook, function(err, text, headers) end, 'POST', json.encode({username = "Döviz Botu", embeds = embeds}), {['Content-Type'] = 'application/json'}) -- webhook'u gönder
else
print("Döviz kurları alınamadı.")
end
end
end)
Güzel bir kod geliştirilebilir benimki gibi.İsteyen varsa bu şekilde de yapabilir sağlam bir APİ bulamadım düzenleyerek kendi discord sunucunuza da aktarırsınız herhangi bir server kodu arasına eklemek yeterli 10 dakika da bir veri gönderiyor
Kod:local webhook = "+" -- Discord webhook URL'si local access_key = "+" -- API anahtarı Citizen.CreateThread(function() while true do Wait(600000) -- 10 dakika bekle local success, response = pcall(PerformHttpRequest, "http://api.currencylayer.com/live?access_key="..access_key.."¤cies=USD,EUR,GBP", function(err, text, headers) if err == 200 then return json.decode(text) else print("Döviz kurları alınamadı. Hata kodu: " .. tostring(err)) end end) if success and response and response.success == true then local usd = response.quotes.USDTRY local eur = response.quotes.EURTRY local gbp = response.quotes.GBPTRY local timestamp = os.date("%d/%m/%Y %X") local embeds = {{ ["title"] = "Döviz Kurları", ["description"] = string.format("Güncel döviz kurları: USD: %.2f, EUR: %.2f, GBP: %.2f", usd, eur, gbp), -- açıklama ["color"] = 16711680, ["timestamp"] = timestamp }} PerformHttpRequest(webhook, function(err, text, headers) end, 'POST', json.encode({username = "Döviz Botu", embeds = embeds}), {['Content-Type'] = 'application/json'}) -- webhook'u gönder else print("Döviz kurları alınamadı.") end end end)
Forumdan daha fazla yararlanmak için giriş yapın veya kayıt olun!