function Registry.RegisterCommandObject(X,D,N)for N in pairs(D)do if X.CommandMethods[N]==nil then error("\085\110\107\110\111\119\110 \107\101\121\047\109\101\116\104\111\100 \105\110 \099\111\109\109\097\110\100 "..((D.Name or"\117\110\107\110\111\119\110 \099\111\109\109\097\110\100")..("\058 "..N)))end end if D.Args then for N,J in pairs(D.Args)do if type(J)=="\116\097\098\108\101"then for J in pairs(J)do if X.CommandArgProps[J]==nil then error(("\085\110\107\110\111\119\110 \112\114\111\112\101\114\121 \105\110 \099\111\109\109\097\110\100 \"\037\115\" \097\114\103\117\109\101\110\116 \035\037\100\058 \037\115"):format(D.Name or"\117\110\107\110\111\119\110",N,J))end end end end end if D.AutoExec and RunService:IsClient()then table.insert(X.AutoExecBuffer,D.AutoExec)X:FlushAutoExecBufferDeferred()end local J=X.Commands[D.Name:lower()]if J and J.Aliases then for D,N in pairs(J.Aliases)do X.Commands[N:lower()]=nil end elseif not J then X.CommandsArray[#X.CommandsArray+1]=D end X.Commands[D.Name:lower()]=D if D.Aliases then for N,J in pairs(D.Aliases)do X.Commands[J:lower()]=D end end end
--- Registers a command based purely on its definition.
-- Prefer using Registry:RegisterCommand for proper handling of server/client model.
function Registry:RegisterCommandObject(commandObject, fromCmdr)
	for key in pairs(commandObject) do
		if self.CommandMethods[key] == nil then
			error("Unknown key/method in command " .. (commandObject.Name or "unknown command") .. ": " .. key)
		end
	end

	if commandObject.Args then
		for i, arg in pairs(commandObject.Args) do
			if type(arg) == "table" then
				for key in pairs(arg) do
					if self.CommandArgProps[key] == nil then
						error(
							('Unknown propery in command "%s" argument #%d: %s'):format(
								commandObject.Name or "unknown",
								i,
								key
							)
						)
					end
				end
			end
		end
	end

	if commandObject.AutoExec and RunService:IsClient() then
		table.insert(self.AutoExecBuffer, commandObject.AutoExec)
		self:FlushAutoExecBufferDeferred()
	end

	-- Unregister the old command if it exists...
	local oldCommand = self.Commands[commandObject.Name:lower()]
	if oldCommand and oldCommand.Aliases then
		for _, alias in pairs(oldCommand.Aliases) do
			self.Commands[alias:lower()] = nil
		end
	elseif not oldCommand then
		self.CommandsArray[#self.CommandsArray + 1] = commandObject
	end

	self.Commands[commandObject.Name:lower()] = commandObject

	if commandObject.Aliases then
		for _, alias in pairs(commandObject.Aliases) do
			self.Commands[alias:lower()] = commandObject
		end
	end
end
