return function(y,s)local N=s(nil,{script=script})setfenv(1,N)local j=y.Server local v=y.Service local E=j.Settings local x,M,R,Q,g,d,T,U,l,V,f local function W()x=j.Functions R=j.Admin Q=j.Anti g=j.Core d=j.HTTP T=j.Logs U=j.Remote l=j.Process V=j.Variables M=j.Commands f=j.Deps setmetatable(M,{__index=function(y,s)local N=R.CommandCache[string.lower(s)]if N then return rawget(M,N)end end;__newindex=function(y,s,N)rawset(M,s,N)if N and(type(N)=="\116\097\098\108\101"and(N.Commands and N.Prefix))then for y,j in pairs(N.Commands)do R.PrefixCache[N.Prefix]=true R.CommandCache[string.lower(N.Prefix..j)]=s end end end})T:AddLog("\083\099\114\105\112\116","\076\111\097\100\105\110\103 \067\111\109\109\097\110\100 \077\111\100\117\108\101\115\046\046\046")if j.CommandModules then local N=s()for s,j in ipairs(j.CommandModules:GetChildren())do local v=require(j)local E,x=pcall(v,y,N)if E and(x and type(x)=="\116\097\098\108\101")then for y,s in pairs(x)do M[y]=s end T:AddLog("\083\099\114\105\112\116","\076\111\097\100\101\100 \067\111\109\109\097\110\100 \077\111\100\117\108\101\058 "..j.Name)elseif not E then warn("\067\077\068\077\079\068\085\076\069 "..(j.Name.." \102\097\105\108\101\100 \116\111 \108\111\097\100\058"))warn(tostring(x))T:AddLog("\083\099\114\105\112\116","\076\111\097\100\105\110\103 \067\111\109\109\097\110\100 \077\111\100\117\108\101 \070\097\105\108\101\100\058 "..j.Name)end end end R.CacheCommands()M.Init=nil T:AddLog("\083\099\114\105\112\116","\067\111\109\109\097\110\100\115 \077\111\100\117\108\101 \073\110\105\116\105\097\108\105\122\101\100")end local function C()for y,s in pairs(E.Commands or{})do if type(s)=="\116\097\098\108\101"and s.Function then setfenv(s.Function,getfenv())M[y]=s end end local y=v.Trim for s,N in pairs(E.Permissions or{})do local j,v=string.match(N,"\094\040\046\042\041\058\040\046\042\041")if j and v then if string.find(v,"\044")then local s={}for N in string.gmatch(v,"\091\094\037\115\044\093\043")do table.insert(s,y(N))end R.SetPermission(j,s)else R.SetPermission(j,v)end end end for y,s in pairs(M)do if type(s)=="\116\097\098\108\101"and s.AdminLevel then local N=s.AdminLevel if type(N)=="\115\116\114\105\110\103"then s.AdminLevel=R.StringToComLevel(N)elseif type(N)=="\116\097\098\108\101"then for y,s in pairs(N)do N[y]=R.StringToComLevel(s)end end if not s.Prefix then s.Prefix=E.Prefix end if s.ListUpdater then T.ListUpdaters[y]=function(y,...)if not y or R.CheckComLevel(R.GetLevel(y),s.AdminLevel)then if type(s.ListUpdater)=="\102\117\110\099\116\105\111\110"then return s.ListUpdater(y,...)end return T[s.ListUpdater]end end end end end M.RunAfterPlugins=nil end j.Commands={Init=W,RunAfterPlugins=C}end
--// Commands
--// Highly recommended you disable Intellesense before editing this...
return function(Vargs, GetEnv)
	local env = GetEnv(nil, { script = script })
	setfenv(1, env)

	local server = Vargs.Server
	local service = Vargs.Service

	local Settings = server.Settings
	local Functions, Commands, Admin, Anti, Core, HTTP, Logs, Remote, Process, Variables, Deps

	local function Init()
		Functions = server.Functions
		Admin = server.Admin
		Anti = server.Anti
		Core = server.Core
		HTTP = server.HTTP
		Logs = server.Logs
		Remote = server.Remote
		Process = server.Process
		Variables = server.Variables
		Commands = server.Commands
		Deps = server.Deps

		--// Automatic New Command Caching and Ability to do server.Commands[":ff"]
		setmetatable(Commands, {
			__index = function(self, ind)
				local targInd = Admin.CommandCache[string.lower(ind)]
				if targInd then
					return rawget(Commands, targInd)
				end
			end,

			__newindex = function(self, ind, val)
				rawset(Commands, ind, val)
				if val and type(val) == "table" and val.Commands and val.Prefix then
					for i, cmd in pairs(val.Commands) do
						Admin.PrefixCache[val.Prefix] = true
						Admin.CommandCache[string.lower((val.Prefix .. cmd))] = ind
					end
				end
			end,
		})

		Logs:AddLog("Script", "Loading Command Modules...")

		--// Load command modules
		if server.CommandModules then
			local env = GetEnv()
			for i, module in ipairs(server.CommandModules:GetChildren()) do
				local func = require(module)
				local ran, tab = pcall(func, Vargs, env)

				if ran and tab and type(tab) == "table" then
					for ind, cmd in pairs(tab) do
						Commands[ind] = cmd
					end

					Logs:AddLog("Script", "Loaded Command Module: " .. module.Name)
				elseif not ran then
					warn("CMDMODULE " .. module.Name .. " failed to load:")
					warn(tostring(tab))
					Logs:AddLog("Script", "Loading Command Module Failed: " .. module.Name)
				end
			end
		end

		--// Cache commands
		Admin.CacheCommands()

		Commands.Init = nil
		Logs:AddLog("Script", "Commands Module Initialized")
	end

	local function RunAfterPlugins()
		--// Load custom user-supplied commands in settings.Commands
		for ind, cmd in pairs(Settings.Commands or {}) do
			if type(cmd) == "table" and cmd.Function then
				setfenv(cmd.Function, getfenv())
				Commands[ind] = cmd
			end
		end

		--// Change command permissions based on settings
		local Trim = service.Trim
		for ind, cmd in pairs(Settings.Permissions or {}) do
			local com, level = string.match(cmd, "^(.*):(.*)")
			if com and level then
				if string.find(level, ",") then
					local newLevels = {}
					for lvl in string.gmatch(level, "[^%s,]+") do
						table.insert(newLevels, Trim(lvl))
					end

					Admin.SetPermission(com, newLevels)
				else
					Admin.SetPermission(com, level)
				end
			end
		end

		--// Update existing permissions to new levels
		for i, cmd in pairs(Commands) do
			if type(cmd) == "table" and cmd.AdminLevel then
				local lvl = cmd.AdminLevel
				if type(lvl) == "string" then
					cmd.AdminLevel = Admin.StringToComLevel(lvl)
					--print("Changed " .. tostring(lvl) .. " to " .. tostring(cmd.AdminLevel))
				elseif type(lvl) == "table" then
					for b, v in pairs(lvl) do
						lvl[b] = Admin.StringToComLevel(v)
					end
				end

				if not cmd.Prefix then
					cmd.Prefix = Settings.Prefix
				end

				if cmd.ListUpdater then
					Logs.ListUpdaters[i] = function(plr, ...)
						if not plr or Admin.CheckComLevel(Admin.GetLevel(plr), cmd.AdminLevel) then
							if type(cmd.ListUpdater) == "function" then
								return cmd.ListUpdater(plr, ...)
							end
							return Logs[cmd.ListUpdater]
						end
					end
				end
			end
		end

		Commands.RunAfterPlugins = nil
	end

	server.Commands = {
		Init = Init,
		RunAfterPlugins = RunAfterPlugins,
	}
end
