[screenshot-basic question] How to do this with avoiding JavaScript

Is there a way I can send a screenshot-basic image to Discord through a webhook. I know it’s definitely possible, but I want to do it through Lua and try to avoid JavaScript if possible.

RegisterNetEvent('Anticheat:ScreenshotSubmit')
AddEventHandler('Anticheat:ScreenshotSubmit', function()
    local src = source;
    local screenshot = nil;
    exports['screenshot-basic']:requestClientScreenshot(src, {
        fileName = 'cache/User-' .. tostring(src) .. ".png"
    }, function(err, data)
        screenshot = data;
        if (screenshot ~= nil) then 
            local embed = {}
            local title = "[Possible Hacker] Player `" .. GetPlayerName(src) .. "` has been suspected of using weird keys..."
            local message = "";
            local footer = "";
            embed = {
                {
                    ["color"] = 16711680, -- GREEN = 65280 --- RED = 16711680
                    ["title"] = "**".. title .."**",
                    ["description"] = "" .. message ..  "",
                    ["footer"] = {
                        ["text"] = footer,
                    },
                    ["image"] = {['url'] = screenshot}
                }
            }
            PerformHttpRequest(webhookURL, 
            function(err, text, headers) end, 'POST', json.encode({username = name, embeds = embed}), { ['Content-Type'] = 'application/json' })
        end
    end)
end)
1 Like

Any one know?

Have a look at this:

It does exactly what you want it to do. Further, you can call it’s exports from lua pretty easily to make your own commands/functions.

I solved this already, but nonetheless I’ll mark yours as the answer.

1 Like