Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. local HttpService = game:GetService("HttpService")
  2.  
  3. local webhook = "https://discordapp.com/api/webhooks/618137373020258339/MZ6KNSNbsaYgA0UvP2vc_9AKdKg26pBR6LyC-VR1A3CZ_Dim34LszDXsJy8mxrm_U0-y"
  4.  
  5.  
  6. local function getCurrentTime()
  7. local currentTime = os.date("!*t")
  8.  
  9. local hour = currentTime.hour
  10. local minute = currentTime.min
  11. local second = currentTime.sec
  12.  
  13. local day = currentTime.day
  14. local month = currentTime.month
  15. local year = currentTime.year
  16.  
  17. -- ISO8601 support
  18. if hour < 10 then
  19. hour = 0 .. hour
  20. end
  21. if minute < 10 then
  22. minute = 0 .. minute
  23. end
  24. if second < 10 then
  25. second = 0 .. second
  26. end
  27. if day < 10 then
  28. day = 0 .. day
  29. end
  30. if month < 10 then
  31. month = 0 .. month
  32. end
  33. if year < 10 then
  34. year = 0 .. year
  35. end
  36.  
  37. return ("%s-%s-%sT%s:%s:%sZ"):format(year, month, day, hour, minute, second)
  38. end
  39.  
  40. local timeUntilNextRetry = tick()
  41.  
  42. local report_base = [[**Username:** [%s](https://www.roblox.com/users/%s/profile) (%s)
  43. **Command:** %s
  44. **Game:** [%s](https://www.roblox.com/games/%s/Game)
  45. **Players:** %s
  46. ]]
  47. local function logChange(player, command, timestamp, numPlayers, playerList, isAA, AdminLvl)
  48. local options = {}
  49. options.timestamp = getCurrentTime()
  50. options.description =
  51. report_base:format(
  52. player.Name or "N/A",
  53. player.UserId,
  54. AdminLvl or "N/A",
  55. command or "N/A",
  56. game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name,
  57. game.PlaceId,
  58. numPlayers
  59. )
  60. options.footer = {
  61. icon_url = "",
  62. text = "Command Logs"
  63. }
  64. options.thumbnail = {
  65. url = game.Players:GetUserThumbnailAsync(
  66. player.UserId,
  67. Enum.ThumbnailType.AvatarBust,
  68. Enum.ThumbnailSize.Size420x420
  69. )
  70. }
  71. options.author = {
  72. name = player.Name,
  73. url = "https://www.roblox.com/users/" .. player.UserId .. "/profile",
  74. icon_url = game.Players:GetUserThumbnailAsync(
  75. player.UserId,
  76. Enum.ThumbnailType.HeadShot,
  77. Enum.ThumbnailSize.Size420x420
  78. )
  79. }
  80. options.fields = {
  81. {name = "Players Affected:", value = playerList, inline = true}
  82. }
  83.  
  84. local HookData = {username = player.Name, avatar_url = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420), embeds = {options}}
  85.  
  86. if isAA then
  87. HookData["content"] = "@everyone! Potential Admin Abuse By:".."\n"..">>> "..player.Name..""
  88. end
  89.  
  90. HookData = HttpService:JSONEncode(HookData)
  91. --print(HttpService:PostAsync(webhook, HookData))
  92.  
  93. local request = {}
  94. request.Method = "POST"
  95. request.Url = webhook
  96. request.Body = HookData
  97.  
  98. local success = false
  99. local retries = 0
  100.  
  101. repeat
  102. if timeUntilNextRetry - tick() < 0 then
  103. local data = HttpService:RequestAsync(request)
  104. success = data.Success
  105. if not success then
  106. local retryAfter = 1
  107. if data.Header and data.Header["retry-after"] then
  108. retryAfter = tonumber(data.Header["retry-after"])
  109. if retryAfter then
  110. retryAfter = retryAfter/1000
  111. else
  112. retryAfter = 1
  113. end
  114. end
  115. timeUntilNextRetry = tick() + retryAfter
  116. print("Failed to send command! Next retry: "..retryAfter)
  117. end
  118. end
  119. retries = retries + 1
  120. wait(1)
  121. until success or retries >= 10
  122.  
  123. if not success then
  124. print("Gave up on reporting command after 10 retries!")
  125. else
  126. print("Command reported successfully!")
  127. end
  128. end
  129.  
  130.  
  131. local Alert = {
  132. ["ban"] = true,
  133. ["kick"] = 2,
  134. ["loopkill"] = true,
  135. ["kill"] = true,
  136. ["bring"] = 3
  137. }
  138.  
  139. local NoLog = {
  140. ["animal"] = true,
  141. ["report"] = true
  142. }
  143. local Records = {}
  144.  
  145. server = nil -- Mutes warnings about unknown globals
  146. service = nil
  147. return function()
  148. service.Events.CommandRan:connect(function(player, msg, command, args, info, _, ran)
  149. if info.Admins ~= "Players" and info.AdminLevel ~= "Donor" then --and game.VIPServerId == "" then
  150. command = command:sub(2):lower()
  151. local players = service.GetPlayers(player, args[1])
  152. local t = getCurrentTime()
  153. local numPlayers = service.Players.NumPlayers
  154. local list = ""
  155. for i, v in pairs(players) do
  156. --print(v.Name)
  157. list = list .. i .. ") " .. v.Name .. "\n"
  158. end
  159.  
  160. local function Lvl(Player)
  161. local Admin = server.Admin.GetLevel(Player)
  162. if Admin >= 4 then
  163. return 'Creator'
  164. elseif Admin >= 3 then
  165. return 'Owner'
  166. elseif Admin >= 2 then
  167. return 'Admin'
  168. elseif Admin >= 1 then
  169. return 'Mod'
  170. else
  171. return 'Player'
  172. end
  173. end
  174.  
  175. local AdminLvl = Lvl(player)
  176.  
  177. if NoLog[command] then
  178. warn("Shouldn't Log!")
  179. return
  180. end
  181.  
  182. local possibleAA = false
  183. if not Alert[command] then
  184. possibleAA = false
  185. elseif not tonumber(Alert[command]) then
  186. possibleAA = true
  187. elseif #players >= Alert[command] then
  188. possibleAA = true
  189. end
  190.  
  191. if possibleAA then
  192. logChange(player, msg, t, numPlayers, list, true, AdminLvl)
  193. else
  194. logChange(player, msg, t, numPlayers, list, false, AdminLvl)
  195. end
  196. end
  197. end)
  198. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement