Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local HttpService = game:GetService("HttpService")
- local webhook = "https://discordapp.com/api/webhooks/618137373020258339/MZ6KNSNbsaYgA0UvP2vc_9AKdKg26pBR6LyC-VR1A3CZ_Dim34LszDXsJy8mxrm_U0-y"
- local function getCurrentTime()
- local currentTime = os.date("!*t")
- local hour = currentTime.hour
- local minute = currentTime.min
- local second = currentTime.sec
- local day = currentTime.day
- local month = currentTime.month
- local year = currentTime.year
- -- ISO8601 support
- if hour < 10 then
- hour = 0 .. hour
- end
- if minute < 10 then
- minute = 0 .. minute
- end
- if second < 10 then
- second = 0 .. second
- end
- if day < 10 then
- day = 0 .. day
- end
- if month < 10 then
- month = 0 .. month
- end
- if year < 10 then
- year = 0 .. year
- end
- return ("%s-%s-%sT%s:%s:%sZ"):format(year, month, day, hour, minute, second)
- end
- local timeUntilNextRetry = tick()
- local report_base = [[**Username:** [%s](https://www.roblox.com/users/%s/profile) (%s)
- **Command:** %s
- **Game:** [%s](https://www.roblox.com/games/%s/Game)
- **Players:** %s
- ]]
- local function logChange(player, command, timestamp, numPlayers, playerList, isAA, AdminLvl)
- local options = {}
- options.timestamp = getCurrentTime()
- options.description =
- report_base:format(
- player.Name or "N/A",
- player.UserId,
- AdminLvl or "N/A",
- command or "N/A",
- game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name,
- game.PlaceId,
- numPlayers
- )
- options.footer = {
- icon_url = "",
- text = "Command Logs"
- }
- options.thumbnail = {
- url = game.Players:GetUserThumbnailAsync(
- player.UserId,
- Enum.ThumbnailType.AvatarBust,
- Enum.ThumbnailSize.Size420x420
- )
- }
- options.author = {
- name = player.Name,
- url = "https://www.roblox.com/users/" .. player.UserId .. "/profile",
- icon_url = game.Players:GetUserThumbnailAsync(
- player.UserId,
- Enum.ThumbnailType.HeadShot,
- Enum.ThumbnailSize.Size420x420
- )
- }
- options.fields = {
- {name = "Players Affected:", value = playerList, inline = true}
- }
- local HookData = {username = player.Name, avatar_url = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420), embeds = {options}}
- if isAA then
- HookData["content"] = "@everyone! Potential Admin Abuse By:".."\n"..">>> "..player.Name..""
- end
- HookData = HttpService:JSONEncode(HookData)
- --print(HttpService:PostAsync(webhook, HookData))
- local request = {}
- request.Method = "POST"
- request.Url = webhook
- request.Body = HookData
- local success = false
- local retries = 0
- repeat
- if timeUntilNextRetry - tick() < 0 then
- local data = HttpService:RequestAsync(request)
- success = data.Success
- if not success then
- local retryAfter = 1
- if data.Header and data.Header["retry-after"] then
- retryAfter = tonumber(data.Header["retry-after"])
- if retryAfter then
- retryAfter = retryAfter/1000
- else
- retryAfter = 1
- end
- end
- timeUntilNextRetry = tick() + retryAfter
- print("Failed to send command! Next retry: "..retryAfter)
- end
- end
- retries = retries + 1
- wait(1)
- until success or retries >= 10
- if not success then
- print("Gave up on reporting command after 10 retries!")
- else
- print("Command reported successfully!")
- end
- end
- local Alert = {
- ["ban"] = true,
- ["kick"] = 2,
- ["loopkill"] = true,
- ["kill"] = true,
- ["bring"] = 3
- }
- local NoLog = {
- ["animal"] = true,
- ["report"] = true
- }
- local Records = {}
- server = nil -- Mutes warnings about unknown globals
- service = nil
- return function()
- service.Events.CommandRan:connect(function(player, msg, command, args, info, _, ran)
- if info.Admins ~= "Players" and info.AdminLevel ~= "Donor" then --and game.VIPServerId == "" then
- command = command:sub(2):lower()
- local players = service.GetPlayers(player, args[1])
- local t = getCurrentTime()
- local numPlayers = service.Players.NumPlayers
- local list = ""
- for i, v in pairs(players) do
- --print(v.Name)
- list = list .. i .. ") " .. v.Name .. "\n"
- end
- local function Lvl(Player)
- local Admin = server.Admin.GetLevel(Player)
- if Admin >= 4 then
- return 'Creator'
- elseif Admin >= 3 then
- return 'Owner'
- elseif Admin >= 2 then
- return 'Admin'
- elseif Admin >= 1 then
- return 'Mod'
- else
- return 'Player'
- end
- end
- local AdminLvl = Lvl(player)
- if NoLog[command] then
- warn("Shouldn't Log!")
- return
- end
- local possibleAA = false
- if not Alert[command] then
- possibleAA = false
- elseif not tonumber(Alert[command]) then
- possibleAA = true
- elseif #players >= Alert[command] then
- possibleAA = true
- end
- if possibleAA then
- logChange(player, msg, t, numPlayers, list, true, AdminLvl)
- else
- logChange(player, msg, t, numPlayers, list, false, AdminLvl)
- end
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement