PerformHttpRequest not working on sending request and discord

I have been trying to solve it but I don’t know what to do next.
Nothing sends to discord I have the real webhook there and no error or anything on console.

client.lua

function customLog(webhook, color, title, message)
    local log = {
        ["color"] = color,
        ["title"] = title,
        ["description"] = message
    }
    print("Client has responded with ")
    print(webhook)
    print(log["color"])
    print(log["title"])
    print(log["description"])
    TriggerServerEvent('core-log:Loki', webhook, log) -- Send to server webhook and log information
end

RegisterNetEvent('core-log:Loki')
AddEventHandler('core-log:Loki', function(webhook, color, title, message)
    customLog(webhook, color, title, message)
end)

RegisterCommand('autokauppa', function(source, args)
    exports['core-log']:customLog('WEBHOOK', '16711680', 'Pelaaja', 'Hankki uuden ajoneuvon. Rekisterillä: LE9E-200')
end, false)

server.lua

RegisterNetEvent('core-log:Loki')
AddEventHandler('core-log:Loki', function(webhook, log)
    if Config.logs then
        Citizen.Wait(1000)
        print("Server has responded with ")
        print(webhook)
        print(log["color"])
        print(log["title"])
        print(log["description"])
        PerformHttpRequest(webhook, function(err, text, headers)
        end, 'POST', json.encode({
            username = "Lokipoliisi",
            embeds = log
        }), {
            ['Content-Type'] = 'application/json'
        })
    else
    end
end)

fxmanifest.lua

fx_version 'cerulean'
games {'gta5'}
author 'author'

client_scripts {'client.lua'}
server_script {'server.lua', 'config.lua'}

export "customLog"

It does not read webhook , you print(webhook) and it returns WEBHOOK , have you put somewhere your webhook link ? In the Config.logs ?

Config.logs is just true/false are the logs enabled or not

You Should Replace ‘WEBHOOK’ With Your Webhook Link Then !

Yes I have it replaced but I just didn’t want to put my webhook link here so I renamed it just WEBHOOK for this example.

It’s not the problem it all goes through server but the PerformHttpRequest doesn’t do what it should.

Alright … Let me think of it … :thinking:

1 Like

Where is this export from ? Does this export works properly ? Cause i dont see anything wrong in your code !

Yes the exports works I did the log in server side and it had all the information from that exports line

1 Like

What do I put on resourcename?

I think exports.core-log.customLog
are same
exports['resourceName']:customLog

Yes they are the same , but try it!

It gives same results its not the export function
because the idea of that is to bring the data to server side and they are there succesfully like you can see on the picture.

1 Like

The client side is fine the problem is on the server side

1 Like

Ok the problem is on the embeds = log,
for some reason it can’t get the log from clientside

1 Like

SOLVED I needed to add 2 times Curly brackets on the client side

Before

    local log = {
        ["color"] = color,
        ["title"] = title,
        ["description"] = message
    }

After

    local log = {{
        ["color"] = color,
        ["title"] = title,
        ["description"] = message
    }}

Ohhhhh Nice ! Good Bye :slightly_smiling_face:

Thanks for help

1 Like