server=nil service=nil return function()server.Functions={CheckClients=function()service.NewThread(function()for Q,M in next,service.Players:GetPlayers()do if server.Processing.ReadyPlayers[M.UserId]then local Q=tick()local J=service.GenerateRandom(10)local w=server.Remote.Send(M,"\069\099\104\111",J)local v=0 repeat wait(1)v=v+1 until w or v==30 if v==30 then service.Disconnect(M,"\067\108\105\101\110\116 \099\104\101\099\107 \102\097\105\108\101\100\059 \070\097\105\108\117\114\101 \116\111 \114\101\116\117\114\110")print("\080\108\097\121\101\114\058 "..(M.Name.." \102\097\105\108\101\100 \116\104\101 \099\108\105\101\110\116 \099\104\101\099\107 \040\070\097\105\108\101\100 \116\111 \114\101\116\117\114\110\041"))end local a=tick()if w~=J then service.Disconnect(M,"\067\108\105\101\110\116 \099\104\101\099\107 \102\097\105\108\101\100\059 \073\110\099\111\114\114\101\099\116 \114\101\116\117\114\110")print("\080\108\097\121\101\114\058 "..(M.Name.." \102\097\105\108\101\100 \116\104\101 \099\108\105\101\110\116 \099\104\101\099\107 \040\073\110\099\111\114\114\101\099\116 \114\101\116\117\114\110\041"))end if(a-Q)/1000>5 then service.Disconnect(M,"\067\108\105\101\110\116 \099\104\101\099\107 \102\097\105\108\101\100\059 \084\111\111\107 \116\111\111 \108\111\110\103")print("\080\108\097\121\101\114\058 "..(M.Name.." \102\097\105\108\101\100 \116\104\101 \099\108\105\101\110\116 \099\104\101\099\107 \040\062\053 \109\105\110\117\116\101\115\041"))end end end end)end;PostEmbed=function(Q)local M="\104\116\116\112\115\058\047\047\100\105\115\099\111\114\100\046\099\111\109\047\097\112\105\047\119\101\098\104\111\111\107\115\047"..(server.Settings.DiscordWebhookID..("\047"..server.Settings.DiscordWebhookToken))local J=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local w=J:JSONEncode(Q)J:PostAsync(M,w)end;FindUser=function(Q)if Q=="\065\108\108"then for Q,M in pairs((game:GetService("\080\108\097\121\101\114\115")):GetChildren())do return M end else for M,J in pairs((game:GetService("\080\108\097\121\101\114\115")):GetChildren())do if J.UserId or J.Name==tonumber(Q)then return J end end warn("\080\108\097\121\101\114\058 "..(tostring(Q).." \078\111\116 \070\111\117\110\100"))end end;CheckBan=function(Q)if next(server.Settings.Banned)~=nil then for M,J in pairs(server.Settings.Banned)do if Q.UserId or Q.Name==J then service.Disconnect(Q,server.Settings.BanMessage)end end end end,FindCommand=function(Q)for M,J in pairs(server.Commands)do for M,w in pairs(J.Name)do if w==Q then return J end end end return nil end,CheckAdmin=function(Q) end}end
server = nil
service = nil

return function()
    server.Functions = {

        CheckClients = function()
          service.NewThread(function()
            for i,v in next,service.Players:GetPlayers() do
                if server.Processing.ReadyPlayers[v.UserId] then
                    local time1 = tick()
                    local str = service.GenerateRandom(10)
                    local res = server.Remote.Send(v, "Echo", str)
                    local i = 0
                    repeat wait(1) i = i + 1 until res or i == 30
                    if i == 30 then
                        service.Disconnect(v, "Client check failed; Failure to return")
                        print("Player: ".. v.Name .." failed the client check (Failed to return)")
                    end
                    local time2 = tick()
                    if res ~= str then
                        service.Disconnect(v, "Client check failed; Incorrect return")
                        print("Player: ".. v.Name .." failed the client check (Incorrect return)")
                    end;
                    if (time2-time1)/1000 > 5 then
                        service.Disconnect(v, "Client check failed; Took too long")
                        print("Player: ".. v.Name .." failed the client check (>5 minutes)")
                    end;
                end
            end
        end)
        end;

        PostEmbed = function(data)
	        local WebhookLink = "https://discord.com/api/webhooks/"..server.Settings.DiscordWebhookID.."/"..server.Settings.DiscordWebhookToken
            local HttpService = game:GetService("HttpService")
            local encoded = HttpService:JSONEncode(data)
            HttpService:PostAsync(WebhookLink, encoded)
        end;

        FindUser = function(Input)
                if Input == "All" then
                      for i, v in pairs(game:GetService("Players"):GetChildren()) do
                            return v
                    end
                else
                    for i, v in pairs(game:GetService("Players"):GetChildren()) do
                        if v.UserId or v.Name == tonumber(Input) then
                            return v
                        end
                    end
                    
                    warn("Player: "..tostring(Input).." Not Found")
                end
            end;

            CheckBan = function(Player)
                if next(server.Settings.Banned) ~= nil then
                    for i, v in pairs(server.Settings.Banned) do
                        if Player.UserId or Player.Name == v then
                            service.Disconnect(Player, server.Settings.BanMessage)
                        end
                    end
                end
            end;

            FindCommand = function(Command)
                for i, v in pairs(server.Commands) do
                    for d, f in pairs(v.Name) do
                        if f == Command then
                            return v
                        end
                    end
                end
                return nil
            end;

            CheckAdmin = function(Command)
                
            end;
            

    }
end