[Release] Server Logs to Discord

Yeah looks all good to me. if you need more help or if you don’t get it to work let me know


For a reason i am getting this error spammed in my console server but the logs work perfectly…What should i do?

Check updated version V1.1.0

Is there no way to change the message scheme to Discord?

Hello i can’t get it to work. I have set everything up

I made the newest showcase of JokeDevil Logs 1.0.4! @JokeDevil
https://www.youtube.com/watch?v=jPzqb--N6RI

1 Like

For anyone having problems with the log sending the logs twice when the “Config.AllLogs” is on, I’ve pushed out a fix in a Pull Request for it at https://github.com/JokeDevil/JD_logs/pulls

For anyone too lazy

Change

function discordLog(message, color, channel)
  if Config.AllLogs then
	PerformHttpRequest(Config.webhooks["all"], function(err, text, headers) end, 'POST', json.encode({username = Config.username, embeds = {{["color"] = color, ["author"] = {["name"] = Config.communtiyName,["icon_url"] = Config.communtiyLogo}, ["description"] = "".. message .."",["footer"] = {["text"] = "© JokeDevil.com - "..os.date("%x %X %p"),["icon_url"] = "https://www.jokedevil.com/img/logo.png",},}}, avatar_url = Config.avatar}), { ['Content-Type'] = 'application/json' })
  end
	PerformHttpRequest(Config.webhooks[channel], function(err, text, headers) end, 'POST', json.encode({username = Config.username, embeds = {{["color"] = color, ["author"] = {["name"] = Config.communtiyName,["icon_url"] = Config.communtiyLogo}, ["description"] = "".. message .."",["footer"] = {["text"] = "© JokeDevil.com - "..os.date("%x %X %p"),["icon_url"] = "https://www.jokedevil.com/img/logo.png",},}}, avatar_url = Config.avatar}), { ['Content-Type'] = 'application/json' })
end```

To

```lua
function discordLog(message, color, channel)
  if Config.AllLogs then
	PerformHttpRequest(Config.webhooks["all"], function(err, text, headers) end, 'POST', json.encode({username = Config.username, embeds = {{["color"] = color, ["author"] = {["name"] = Config.communtiyName,["icon_url"] = Config.communtiyLogo}, ["description"] = "".. message .."",["footer"] = {["text"] = "© JokeDevil.com - "..os.date("%x %X %p"),["icon_url"] = "https://www.jokedevil.com/img/logo.png",},}}, avatar_url = Config.avatar}), { ['Content-Type'] = 'application/json' })
  else
	PerformHttpRequest(Config.webhooks[channel], function(err, text, headers) end, 'POST', json.encode({username = Config.username, embeds = {{["color"] = color, ["author"] = {["name"] = Config.communtiyName,["icon_url"] = Config.communtiyLogo}, ["description"] = "".. message .."",["footer"] = {["text"] = "© JokeDevil.com - "..os.date("%x %X %p"),["icon_url"] = "https://www.jokedevil.com/img/logo.png",},}}, avatar_url = Config.avatar}), { ['Content-Type'] = 'application/json' })
  end
end```

You can find this on line 44-50 on the server/server.lua

that’s because the all logs channel will get all logs regardless if you send them there :wink:
if you only want it in the all logs you just don’t put a webhook in your other channels.

or just put Config.AllLogs to false if you’re not using tha all logs channel

1 Like

True but I put them in all channels and that fixed my problems I had there :stuck_out_tongue:

1 Like

1.1.0 :wink:

IDK whats going on, I installed everything but for some reason I cant get the logs to show up in Discord. Any Thoughts?

// in config
robbery 	= "https://discordapp.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

// in server or client i placed this
exports.JD_logs:discord(GetPlayerName(source)..' started a Vangelico Jewelries Robbery', '1752220', 'robbery')

i correctly add that but i can’t logs it to my discord how can i fix that ?

check your webhooks and make sure you have the < > remove in the config.lua

exports function has been updated in V1.1.0
This one should work:

exports.JD_logs:discord(GetPlayerName(source)..' started a Vangelico Jewelries Robbery',source,0, '1752220', 'robbery')
1 Like

i will try it later, anyway i would like to request if its ok to add IP address logs on Player connect/Disconnect for IP Ban in case of modder, it’ll usefull

image
Yes, it work 100%!

And thank you very much, it’s very complete!
Nice job! :ok_hand:

1 Like

Yeah I removed those but still nothing…I tried other log scripts and they work but I dont like them so I wanted this one but I cant get it…not sure

was out of town for a few days but finally updated to the latest version last night and it looks like everything is working great for us now!!! Thanks for the great work!!!

1 Like

Hey,
Sorry I am new. How Would I add logging to this code? Once I see how to do it for this I will get it for the rest! Thanks for your time @JokeDevil

AddEventHandler('chatMessage', function(source, color, msg)
    cm = stringsplit(msg, " ")
    if cm[1] == "/pm" or cm[1] == "/privatemessage" then
        CancelEvent()
            if tablelength(cm) > 1 then
            local ptid = tonumber(cm[2])
            local player2 = GetPlayerName(ptid)
            local player1 = GetPlayerName(source)
            local msgVar = {}
            local textmsg = ""
            for i=1, #cm do
                if i ~= 1 and i ~= 2 then
                    textmsg = (textmsg .. " " .. tostring(cm[i]))
                end
            end
            TriggerClientEvent('simp:textmsg', ptid, source, textmsg, player2, player1)
            TriggerClientEvent('simp:textsent', source, ptid, player2, textmsg)
        end
    end
end)

This should work perfectly fine

AddEventHandler('chatMessage', function(source, color, msg)
    cm = stringsplit(msg, " ")
    if cm[1] == "/pm" or cm[1] == "/privatemessage" then
        CancelEvent()
            if tablelength(cm) > 1 then
            local ptid = tonumber(cm[2])
            local player2 = GetPlayerName(ptid)
            local player1 = GetPlayerName(source)
            local msgVar = {}
            local textmsg = ""
            for i=1, #cm do
                if i ~= 1 and i ~= 2 then
                    textmsg = (textmsg .. " " .. tostring(cm[i]))
                end
            end
            TriggerClientEvent('simp:textmsg', ptid, source, textmsg, player2, player1)
            TriggerClientEvent('simp:textsent', source, ptid, player2, textmsg)
            -- To send a log you can use the export function:
            -- exports.JD_logs:discord('MESSAGE_YOU_WANT_TO_POST_IN_THE_EMBED', PLAYER_ID, PLAYER_2_ID, 'DECIMAL_COLOR_CODE', 'WEBHOOK_CHANNEL')
            exports.JD_logs:discord(player1..' Send a PM to '..player2..'\nMessage: 'textmsg, source, ptid, '3241202', 'chat')

        end
    end
end)

You can find more info on the export function here

Hey @JokeDevil I am getting this error from the code you sent:
Error parsing script @privateM/server.lua in resource privateM: @privateM/server.lua:20: ‘)’ expected near ‘textmsg’
Here is the code:

AddEventHandler('chatMessage', function(source, color, msg)
    cm = stringsplit(msg, " ")
    if cm[1] == "/pm" or cm[1] == "/privatemessage" then
        CancelEvent()
            if tablelength(cm) > 1 then
            local ptid = tonumber(cm[2])
            local player2 = GetPlayerName(ptid)
            local player1 = GetPlayerName(source)
            local msgVar = {}
            local textmsg = ""
            for i=1, #cm do
                if i ~= 1 and i ~= 2 then
                    textmsg = (textmsg .. " " .. tostring(cm[i]))
                end
            end
            TriggerClientEvent('simp:textmsg', ptid, source, textmsg, player2, player1)
            TriggerClientEvent('simp:textsent', source, ptid, player2, textmsg)
			-- To send a log you can use the export function:
            -- exports.JD_logs:discord('MESSAGE_YOU_WANT_TO_POST_IN_THE_EMBED', PLAYER_ID, PLAYER_2_ID, 'DECIMAL_COLOR_CODE', 'WEBHOOK_CHANNEL')
            exports.JD_logs:discord(player1..' Send a PM to '..player2..'\nMessage: 'textmsg, source, ptid, '3241202', 'privatemessages')

        end
    end
end)