function Registry.RegisterCommandObject(N,s)for g in pairs(s)do if N.CommandMethods[g]==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 "..((s.Name or"\117\110\107\110\111\119\110 \099\111\109\109\097\110\100")..("\058 "..g)))end end if s.Args then for g,b in pairs(s.Args)do for b in pairs(b)do if N.CommandArgProps[b]==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(s.Name or"\117\110\107\110\111\119\110",g,b))end end end end if RunService:IsClient()and(s.Data and s.Run)then error(("\073\110\118\097\108\105\100 \099\111\109\109\097\110\100 \105\109\112\108\101\109\101\110\116\097\116\105\111\110 \112\114\111\118\105\100\101\100 \102\111\114 \"\037\115\"\058 \"\068\097\116\097\" \097\110\100 \"\082\117\110\" \115\101\099\116\105\111\110\115 \097\114\101 \109\117\116\117\097\108\108\121 \101\120\099\108\117\115\105\118\101"):format(s.Name or"\117\110\107\110\111\119\110"))end if s.AutoExec and RunService:IsClient()then table.insert(N.AutoExecBuffer,s.AutoExec)N:FlushAutoExecBufferDeferred()end local g=N.Commands[s.Name:lower()]if g and g.Aliases then for s,g in pairs(g.Aliases)do N.Commands[g:lower()]=nil end elseif not g then N.CommandsArray[#N.CommandsArray+1]=s end N.Commands[s.Name:lower()]=s if s.Aliases then for g,b in pairs(s.Aliases)do N.Commands[b:lower()]=s 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)
	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
			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

	if RunService:IsClient() and commandObject.Data and commandObject.Run then
		error(
			('Invalid command implementation provided for "%s": "Data" and "Run" sections are mutually exclusive'):format(
				commandObject.Name or "unknown"
			)
		)
	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
