local E=game:GetService("\082\117\110\083\101\114\118\105\099\101")local Y=(script:FindFirstAncestor("\067\109\100\114\065\100\100\105\116\105\111\110\115")).Commands local O={}O.__index=O function O.new(E)return setmetatable({Config=E},O)end function O.SetCmdr(x,O)assert(not x.Cmdr,"\083\101\116\067\109\100\114 \099\097\110 \111\110\108\121 \098\101 \099\097\108\108\101\100 \111\110\099\101\033")x.Cmdr=O O.CmdrAdditions=x for Y,x in pairs(Y:GetChildren())do local L=require(x)O.Registry:RegisterCommandObject({Name=L.Id:lower(),Aliases=L.Aliases;Description=L.Description;Args=L.Args;Group="\067\109\100\114\065\100\100\105\116\105\111\110\115";Run=E:IsServer()and L.RunServer or E:IsClient()and L.RunClient or nil},true)end O.Registry:RegisterHook("\066\101\102\111\114\101\082\117\110",function(E)E.CmdrAdditions=x end)end return O
local RunService = game:GetService("RunService")

local Commands = script:FindFirstAncestor("CmdrAdditions").Commands

local Base = {}
Base.__index = Base

function Base.new(config)
	return setmetatable({
		Config = config
	}, Base)
end

function Base:SetCmdr(cmdr)
	assert(not self.Cmdr, "SetCmdr can only be called once!")
	self.Cmdr = cmdr
	cmdr.CmdrAdditions = self

	-- Register commands
	for _, commandModule in pairs(Commands:GetChildren()) do
		local command = require(commandModule)

		cmdr.Registry:RegisterCommandObject({
			Name = command.Id:lower(),
			Aliases = command.Aliases,
			Description = command.Description,
			Args = command.Args,

			Group = "CmdrAdditions",
			Run = RunService:IsServer() and command.RunServer
				or RunService:IsClient() and command.RunClient
				or nil
		}, true)
	end

	-- Add CmdrAdditions property to every CommandContext
	cmdr.Registry:RegisterHook("BeforeRun", function(context)
		context.CmdrAdditions = self
	end)
end

return Base