Information
Thank you for taking your time and reading this, this is a simple Objected Oriented Programming Discord Logging system, this system simply just logs every player that joins with the game JobId along with the epoch time on the bottom of the embed, Overall this is my first “Open sourced” system I have made, let me know your feedback and more things I should open source
Preview:
Source Code
Script: Location: ServerScriptService
local Player = game:GetService("Players")
-- // Module
local Module = require(script.ModuleScript)
-- //
Player.PlayerAdded:Connect(function(plr)
local GetPlayerInfo = Module.AddPlayer(plr)
GetPlayerInfo:SendInfo()
end)
Module Script: Location: Inside the parent of the Script Above
--[[
- Thigbr
- 03/25/21
- Open Sourced [03/25/21]
- Simple Object Oriented Programming, Logging system
]]
-- // Services
local http = game:GetService("HttpService")
-- // Configuration
local DiscordWebhook = "https://discord.com/api/webhooks/823719482911883265/clBrrx2sC_EfB0bAiI-CFt-v9btSnWsg8j4Tpssrp6ygEnGya2ONK7240Ni2I3SLwOg0"
-- //
local module = {}
module.__index = module
function getRealTime(Time)
local ExactTime = os.date("!*t",Time)
local Hr, min, sec, day, mnth, year = ExactTime.hour, ExactTime.min, ExactTime.sec, ExactTime.day, ExactTime.month, ExactTime.year
return ("%0.0f-%0.0f-%0.0fT%0.0f:%0.0f:%0.0fZ"):format(year, mnth, day, Hr, min, sec)
end
function module.AddPlayer(plr)
local self = setmetatable({
Player = plr.Name;
UserId = plr.UserId;
}, module)
return self
end
function module:SendInfo()
local data = {
embeds = {
{
author = {name = "Player Joined!"},
title = "Server: "..game.JobId,
description = self.Player..":"..self.UserId..' Has joined the server',
timestamp = getRealTime(tick()),
color = "2053964",
type = "rich",
}
}
}
local newdata = http:JSONEncode(data)
http:PostAsync(DiscordWebhook,newdata)
end
return module
Credits
@thigbr - Creator