local d={}local D={}D.__index=D local P=script.Parent.Parent.Parent local q=game:GetService("\067\104\097\116")local B=P:WaitForChild("\067\108\105\101\110\116\067\104\097\116\077\111\100\117\108\101\115")local y=B:WaitForChild("\067\111\109\109\097\110\100\077\111\100\117\108\101\115")local b=require(y:WaitForChild("\085\116\105\108"))local R=script.Parent local m=require(B:WaitForChild("\067\104\097\116\083\101\116\116\105\110\103\115"))function D.SetupCommandProcessors(d)local D=y:GetChildren()for P=1,#D,1 do if D[P]:IsA("\077\111\100\117\108\101\083\099\114\105\112\116")then if D[P].Name~="\085\116\105\108"then local q=require(D[P])local B=q[b.KEY_COMMAND_PROCESSOR_TYPE]local y=q[b.KEY_PROCESSOR_FUNCTION]if B==b.IN_PROGRESS_MESSAGE_PROCESSOR then table.insert(d.InProgressMessageProcessors,y)elseif B==b.COMPLETED_MESSAGE_PROCESSOR then table.insert(d.CompletedMessageProcessors,y)end end end end end function D.ProcessCompletedChatMessage(P,d,D)for q=1,#P.CompletedMessageProcessors,1 do local B=P.CompletedMessageProcessors[q](d,D,m)if B then return true end end return false end function D.ProcessInProgressChatMessage(q,d,D,P)for B=1,#q.InProgressMessageProcessors,1 do local y=q.InProgressMessageProcessors[B](d,D,P,m)if y then return y end end return nil end function d.new()local d=setmetatable({},D)d.CompletedMessageProcessors={}d.InProgressMessageProcessors={}d:SetupCommandProcessors()return d end return d
--!nonstrict
--	// FileName: ProcessCommands.lua
--	// Written by: TheGamer101
--	// Description: Module for processing commands using the client CommandModules

local module = {}
local methods = {}
methods.__index = methods

--////////////////////////////// Include
--//////////////////////////////////////
local chatFolder = script.Parent.Parent.Parent

local Chat = game:GetService("Chat")
local clientChatModules = chatFolder:WaitForChild("ClientChatModules")
local commandModules = clientChatModules:WaitForChild("CommandModules")
local commandUtil = require(commandModules:WaitForChild("Util"))
local modulesFolder = script.Parent
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))

function methods:SetupCommandProcessors()
	local commands = commandModules:GetChildren()
	for i = 1, #commands do
		if commands[i]:IsA("ModuleScript") then
			if commands[i].Name ~= "Util" then
				local commandProcessor = require(commands[i])
				local processorType = commandProcessor[commandUtil.KEY_COMMAND_PROCESSOR_TYPE]
				local processorFunction = commandProcessor[commandUtil.KEY_PROCESSOR_FUNCTION]
				if processorType == commandUtil.IN_PROGRESS_MESSAGE_PROCESSOR then
					table.insert(self.InProgressMessageProcessors, processorFunction)
				elseif processorType == commandUtil.COMPLETED_MESSAGE_PROCESSOR then
					table.insert(self.CompletedMessageProcessors, processorFunction)
				end
			end
		end
	end
end

function methods:ProcessCompletedChatMessage(message, ChatWindow)
	for i = 1, #self.CompletedMessageProcessors do
		local processedCommand = self.CompletedMessageProcessors[i](message, ChatWindow, ChatSettings)
		if processedCommand then
			return true
		end
	end
	return false
end

function methods:ProcessInProgressChatMessage(message, ChatWindow, ChatBar)
	for i = 1, #self.InProgressMessageProcessors do
		local customState = self.InProgressMessageProcessors[i](message, ChatWindow, ChatBar, ChatSettings)
		if customState then
			return customState
		end
	end
	return nil
end

--///////////////////////// Constructors
--//////////////////////////////////////

function module.new()
	local obj = setmetatable({}, methods)

	obj.CompletedMessageProcessors = {}
	obj.InProgressMessageProcessors = {}

	obj:SetupCommandProcessors()

	return obj
end

return module
