Advertisement
Guest User

Adonis Admin Command Logs

a guest
Aug 20th, 2019
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.30 KB | None | 0 0
  1. --[[
  2. Adonis plugin. Place this into the Config.Plugins folder for Adonis.
  3.  
  4. To use this, you need to copy paste your webhook from the discord channel into
  5. the line below, where it says (local webhook = "CODE_HERE"). It should look something like...
  6.  
  7. local webhook = "https://discordapp.com/api/webhooks/g2ga9HF5s2321Gadi"
  8.  
  9. except longer. The above code is just random letters and numbers, it's not a real webhook
  10.  
  11. Also make sure Http requests are enabled.
  12.  
  13. Made by: WrathOfTheElvhen
  14. Edited by: GodDharma
  15. Edit: Report all commands
  16. ]]
  17.  
  18. local HttpService = game:GetService("HttpService")
  19.  
  20. local webhook = "Webhook_Here"
  21.  
  22. local function getCurrentTime()
  23.     local currentTime = os.date("!*t")
  24.  
  25.     local hour = currentTime.hour
  26.     local minute = currentTime.min
  27.     local second = currentTime.sec
  28.  
  29.     local day = currentTime.day
  30.     local month = currentTime.month
  31.     local year = currentTime.year
  32.  
  33.     -- ISO8601 support
  34.     if hour < 10 then
  35.         hour = 0 .. hour
  36.     end
  37.     if minute < 10 then
  38.         minute = 0 .. minute
  39.     end
  40.     if second < 10 then
  41.         second = 0 .. second
  42.     end
  43.     if day < 10 then
  44.         day = 0 .. day
  45.     end
  46.     if month < 10 then
  47.         month = 0 .. month
  48.     end
  49.     if year < 10 then
  50.         year = 0 .. year
  51.     end
  52.  
  53.     return ("%s-%s-%sT%s:%s:%sZ"):format(year, month, day, hour, minute, second)
  54. end
  55.  
  56. local timeUntilNextRetry = tick()
  57.  
  58. local report_base = [[**Username:**   [%s](https://www.roblox.com/users/%s/profile) (%s)
  59. **Command:**   %s
  60. **Game:**   [%s](https://www.roblox.com/games/%s/Game)
  61. **Players:**   %s
  62. ]]
  63. local function logChange(player, command, timestamp, numPlayers, playerList)
  64.     local options = {}
  65.     options.timestamp = getCurrentTime()
  66.     options.description =
  67.         report_base:format(
  68.         player.Name or "N/A",
  69.         player.UserId,
  70.         player:GetRoleInGroup(3587367) or "N/A",
  71.         command or "N/A",
  72.         game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name,
  73.         game.PlaceId,
  74.         numPlayers
  75.     )
  76.     options.footer = {
  77.         icon_url = "",
  78.         text = "Command Logs"
  79.     }
  80.     options.thumbnail = {
  81.         url = game.Players:GetUserThumbnailAsync(
  82.             player.UserId,
  83.             Enum.ThumbnailType.AvatarBust,
  84.             Enum.ThumbnailSize.Size420x420
  85.         )
  86.     }
  87.     options.author = {
  88.         name = player.Name,
  89.         url = "https://www.roblox.com/users/" .. player.UserId .. "/profile",
  90.         icon_url = game.Players:GetUserThumbnailAsync(
  91.             player.UserId,
  92.             Enum.ThumbnailType.HeadShot,
  93.             Enum.ThumbnailSize.Size420x420
  94.         )
  95.     }
  96.         options.fields = {
  97.             {name = "THE FOLLOWING PLAYERS WERE AFFECTED", value = playerList, inline = true}
  98.         }
  99.    
  100.     local HookData = {username = player.Name, avatar_url = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420), embeds = {options}}
  101.    
  102.     HookData = HttpService:JSONEncode(HookData)
  103.     --print(HttpService:PostAsync(webhook, HookData))
  104.    
  105.     local request = {}
  106.     request.Method = "POST"
  107.     request.Url = webhook
  108.     request.Body = HookData
  109.    
  110.     local success = false
  111.     local retries = 0
  112.    
  113.     repeat
  114.         if timeUntilNextRetry - tick() < 0 then
  115.             local data = HttpService:RequestAsync(request)
  116.             success = data.Success
  117.             if not success then
  118.                 local retryAfter = 1
  119.                 if data.Header and data.Header["retry-after"] then
  120.                     retryAfter = tonumber(data.Header["retry-after"])
  121.                     if retryAfter then
  122.                         retryAfter = retryAfter/1000
  123.                     else
  124.                         retryAfter = 1
  125.                     end
  126.                 end
  127.                 timeUntilNextRetry = tick() + retryAfter
  128.                 print("Failed to send command! Next retry: "..retryAfter)
  129.             end
  130.         end
  131.         retries = retries + 1
  132.         wait(1)
  133.     until success or retries >= 10
  134.    
  135.     if not success then
  136.         print("Gave up on reporting command after 10 retries!")
  137.     else
  138.         print("Command reported successfully!")
  139.     end
  140. end
  141.  
  142. local Records = {}
  143.  
  144. server = nil -- Mutes warnings about unknown globals
  145. service = nil
  146. return function()
  147.     service.Events.CommandRan:connect(function(player, msg, command, args, info, _, ran)
  148.         if info.Admins ~= "Players" and info.AdminLevel ~= "Donor" then --and game.VIPServerId == "" then
  149.             command = command:sub(2):lower()
  150.             local players = service.GetPlayers(player, args[1])
  151.             local t = getCurrentTime()
  152.             local numPlayers = service.Players.NumPlayers
  153.             local list = ""
  154.             for i, v in pairs(players) do
  155.                 --print(v.Name)
  156.                 list = list .. i .. ") " .. v.Name .. "\n"
  157.             end
  158.                 logChange(player, msg, t, numPlayers, list)
  159.         end
  160.     end)
  161. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement