From ccb727c800d3c7029a0f569e31c4f453dccc411b Mon Sep 17 00:00:00 2001 From: omwot <140683870+omwot@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:22:43 -0500 Subject: [PATCH] Remove audit logs (#1698) --- MainModule/Server/Commands/HeadAdmins.luau | 68 +--------------------- MainModule/Server/Commands/Players.luau | 8 +-- MainModule/Server/Core/Functions.luau | 42 +++---------- MainModule/Server/Core/Logs.luau | 1 - 4 files changed, 14 insertions(+), 105 deletions(-) diff --git a/MainModule/Server/Commands/HeadAdmins.luau b/MainModule/Server/Commands/HeadAdmins.luau index af7e8622ed..c09017be13 100644 --- a/MainModule/Server/Commands/HeadAdmins.luau +++ b/MainModule/Server/Commands/HeadAdmins.luau @@ -1,7 +1,6 @@ return function(Vargs, env) local server = Vargs.Server; local service = Vargs.Service; - local AuditLogsDataStore = service.DataStoreService:GetDataStore("AdonisAuditLogsDataStore") local Settings = server.Settings local Functions, Commands, Admin, Anti, Core, HTTP, Logs, Remote, Process, Variables, Deps = server.Functions, server.Commands, server.Admin, server.Anti, server.Core, server.HTTP, server.Logs, server.Remote, server.Process, server.Variables, server.Deps @@ -170,7 +169,7 @@ return function(Vargs, env) Description = "Makes the target player(s) a temporary admin; does not save"; AdminLevel = "HeadAdmins"; Dangerous = true; - Function = function(plr: Player, args: {string}, data: {}) + Function = function(plr: Player, args: {string}, data: any) local senderLevel = data.PlayerData.Level for _, v in service.GetPlayers(plr, assert(args[1], "Missing target player (argument #1)")) do @@ -193,7 +192,7 @@ return function(Vargs, env) Description = "Makes the target player(s) an admin; saves"; AdminLevel = "HeadAdmins"; Dangerous = true; - Function = function(plr: Player, args: {string}, data: {}) + Function = function(plr: Player, args: {string}, data: any) local senderLevel = data.PlayerData.Level for _, v in service.GetPlayers(plr, assert(args[1], "Missing target user (argument #1)"), { @@ -423,7 +422,7 @@ return function(Vargs, env) hide_character=hideCharacter } if hideCharacter then - v.CharacterAdded:Connect(function(character: Model) + v.CharacterAdded:Connect(function(character: Model) for _, otherPlr: Player in service.Players:GetPlayers(v, if hidefromEveryone then "others" else "nonadmins") do if otherPlr == v then continue end Remote.LoadCode(otherPlr, [[ @@ -530,66 +529,5 @@ return function(Vargs, env) end }; - AuditLogs = { - Prefix = Settings.Prefix; - Commands = {"auditlogs", "moderationlogs", "modlogs"}; - Args = {"player"}; - Description = "Fetches the recent moderation activity logs of the specified moderator or admin."; - AdminLevel = "HeadAdmins"; - Function = function(plr: Player, args: {string}) - local targetPlayers = service.GetPlayers(plr, args[1], {NoFakePlayer = true}) - - if #targetPlayers == 0 then - Functions.Hint("No player found with the specified name.", {plr}) - return - end - - for _, targetPlayer in ipairs(targetPlayers) do - local userId = targetPlayer.UserId - local key = "AuditLogs_" .. tostring(userId) - - local success, auditLogs = pcall(function() - return AuditLogsDataStore:GetAsync(key) or {} - end) - - if not success then - warn("Failed to retrieve audit logs for UserId " .. tostring(userId) .. ": " .. auditLogs) - Functions.Hint("Error retrieving logs.", {plr}) - return - end - - local filteredLogs = {} - print("Checking audit logs for:", targetPlayer.Name, "with UserId:", userId) - print(auditLogs) - - for _, log in ipairs(auditLogs) do - local moderatorName = Functions.GetNameFromUserIdAsync(log.ModeratorId) or "Unknown" - local targetUserName = log.TargetPlayer - - if type(targetUserName) == "table" then - targetUserName = targetUserName.Name or "Unknown" - elseif targetUserName == nil then - targetUserName = "Unknown" - end - - local timestamp = os.date("%Y-%m-%d %H:%M:%S", log.Time) - - local logText = string.format("%s | %s | %s", moderatorName, log.Action, timestamp) - local logEntry = { Text = logText .. " | " .. targetUserName, Desc = log.Details } - table.insert(filteredLogs, logEntry) - end - - if #filteredLogs == 0 then - Functions.Hint(`No audit logs found for {targetPlayer.Name}`, {plr}) - else - Remote.MakeGui(plr, "List", { - Title = `Audit Logs for {targetPlayer.Name}`, - Table = filteredLogs, - Update = "filteredLogs" - }) - end - end - end - }; } end diff --git a/MainModule/Server/Commands/Players.luau b/MainModule/Server/Commands/Players.luau index 92508c8845..5add1d2537 100644 --- a/MainModule/Server/Commands/Players.luau +++ b/MainModule/Server/Commands/Players.luau @@ -179,7 +179,7 @@ return function(Vargs, env) Args = {"num m", "num n"}; Description = "Generates a number using Lua's math.random"; AdminLevel = "Players"; - Function = function(plr: Player, args: {string}) + Function = function(plr: Player, args: {any}) assert((not args[1]) or tonumber(args[1]), "Argument(s) provided must be numbers") assert((not args[2]) or tonumber(args[2]), "Arguments provided must be numbers") @@ -260,7 +260,7 @@ return function(Vargs, env) "Rock", "Glacier", "Snow", "Sandstone", "Mud", "Basalt", "Ground", "CrackedLava", "Asphalt", "LeafyGrass", "Salt", "Limestone", "Pavement" } for i, mat in mats do - mats[i] = {Text = mat; Desc = `Enum value: {Enum.Material[mat].Value}`} + mats[i] = {Text = mat; Desc = `Enum value: {(Enum.Material[mat]::Enum.Material).Value}`} end Remote.MakeGui(plr, "List", {Title = "Materials"; Tab = mats; TextSelectable = true;}) end @@ -455,12 +455,12 @@ return function(Vargs, env) local UserId = Functions.GetUserIdFromNameAsync(args[1]) if UserId then local success, samePlace, errorMessage, placeId, jobId = pcall(service.TeleportService.GetPlayerPlaceInstanceAsync, service.TeleportService, UserId) - + if success then if samePlace then error("You're already in this server!") end - + if placeId and jobId then service.TeleportService:TeleportAsync(placeId, {plr}, service.New("TeleportOptions", { ServerInstanceId = jobId diff --git a/MainModule/Server/Core/Functions.luau b/MainModule/Server/Core/Functions.luau index 6e8692fc11..5b782d02d9 100644 --- a/MainModule/Server/Core/Functions.luau +++ b/MainModule/Server/Core/Functions.luau @@ -7,9 +7,6 @@ return function(Vargs, GetEnv) local service = Vargs.Service local logError - local AuditLogsDataStore; pcall(function() - AuditLogsDataStore = service.DataStoreService:GetDataStore("AdonisAuditLogsDataStore") - end) local Functions, Admin, Anti, Core, HTTP, Logs, Remote, Process, Variables, Settings local function Init() Functions = server.Functions; @@ -1048,30 +1045,7 @@ return function(Vargs, GetEnv) end; LogAdminAction = function(plr, action, targetPlayerName, additionalDetails) - local logEntry = { - Timestamp = os.time(), - ModeratorId = plr.UserId, - ModeratorName = plr.Name, - Action = action, - TargetPlayer = targetPlayerName, - AdditionalDetails = additionalDetails or "N/A", - } - - -- Attempt to log the action under the moderator's UserId - local key = "AuditLogs_" .. tostring(plr.UserId) - - local success, errMessage = pcall(function() - -- Get existing logs - local existingLogs = AuditLogsDataStore:GetAsync(key) or {} - table.insert(existingLogs, logEntry) - AuditLogsDataStore:SetAsync(key, existingLogs) - end) - - if not success then - warn("Failed to log audit entry for UserId " .. tostring(plr.UserId) .. ": " .. errMessage) - else - print("Audit log entry saved for:", plr.Name) - end + -- kept function here for potential future reimplementation end; NewParticle = function(target, particleType, props) @@ -1585,7 +1559,7 @@ return function(Vargs, GetEnv) local Humanoid: Humanoid = plr.Character and plr.Character:FindFirstChildOfClass("Humanoid") local HumanoidDescription = Humanoid:GetAppliedDescription() or service.Players:GetHumanoidDescriptionFromUserId(plr.UserId) - local newCharacterModel: Model = service.Players:CreateHumanoidModelFromDescription(HumanoidDescription, rigType, Enum.AssetTypeVerification.Always) + local newCharacterModel: any = service.Players:CreateHumanoidModelFromDescription(HumanoidDescription, rigType, Enum.AssetTypeVerification.Always) local Animate: BaseScript = newCharacterModel.Animate newCharacterModel.Humanoid.DisplayName = Humanoid.DisplayName @@ -1632,7 +1606,7 @@ return function(Vargs, GetEnv) }) end; - ParseColor3 = function(str: string?) + ParseColor3 = function(str: string) if not str then return nil end if str:lower() == "random" then return Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255)) @@ -1644,17 +1618,15 @@ return function(Vargs, GetEnv) end if #color == 3 then - color = Color3.fromRGB(color[1], color[2], color[3]) + return Color3.fromRGB(color[1], color[2], color[3]) else - local brickColor = BrickColor.new(str) + local brickColor = BrickColor.new(str::any); if str == tostring(brickColor) then - color = brickColor.Color + return brickColor.Color else return end end - - return color end; ParseBrickColor = function(str: string, allowNil: boolean?) @@ -1665,7 +1637,7 @@ return function(Vargs, GetEnv) return BrickColor.random() end - local brickColor = BrickColor.new(str) + local brickColor = BrickColor.new(str::any) if str == tostring(brickColor) then return brickColor else diff --git a/MainModule/Server/Core/Logs.luau b/MainModule/Server/Core/Logs.luau index 1bee9183fc..2cb2a6436b 100644 --- a/MainModule/Server/Core/Logs.luau +++ b/MainModule/Server/Core/Logs.luau @@ -116,7 +116,6 @@ return function(Vargs, GetEnv) GetAuditLogs = function(playerId) local auditLogs = {} - local logs = Logs.AuditLogs:GetAsTable() or {} for _, log in pairs(Logs.AuditLogs:GetAsTable()) do if log.ModeratorId == playerId then table.insert(auditLogs, log)