Skip to content

Commit 003233d

Browse files
authored
Merge pull request #1 from Tazi0/embed
Main push (of embeds)
2 parents 765f476 + 2717b64 commit 003233d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Serverlogging/server.lua

+18-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ AddEventHandler('chatMessage', function(source, name, message)
2424
end)
2525

2626
AddEventHandler('playerConnecting', function()
27-
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```CSS\n".. GetPlayerName(source) .. " connecting\n```", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
27+
--PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```CSS\n".. GetPlayerName(source) .. " connecting\n```", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
28+
sendToDiscord("Server Login", GetPlayerName(source) " is connecting to the server.")
2829
end)
2930

3031
AddEventHandler('playerDropped', function(reason)
31-
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```fix\n".. GetPlayerName(source) .. " left ( ".. reason .. " )\n```", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
32+
--PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```fix\n".. GetPlayerName(source) .. " left ( ".. reason .. " )\n```", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
33+
sendToDiscord("Server Logout", GetPlayerName(source) " has disconnected from the server.")
3234
end)
3335

3436
RegisterServerEvent('playerDied')
@@ -70,4 +72,18 @@ function stringsplit(input, seperator)
7072
end
7173

7274
return t
75+
end
76+
77+
function sendToDiscord(name, message)
78+
local connect = {
79+
{
80+
["color"] = "8663711",
81+
["title"] = "**".. name .."**",
82+
["description"] = message,
83+
["footer"] = {
84+
["text"] = "Made by Tazio",
85+
},
86+
}
87+
}
88+
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, embeds = connect, avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
7389
end

0 commit comments

Comments
 (0)