-- Compiled with roblox-ts v3.0.0 local TS = _G[script] local Players = TS.import(script, TS.getModule(script, "@rbxts", "services")).Players local _string = TS.import(script, script.Parent.Parent.Parent, "utils", "string") local containsSpace = _string.containsSpace local getQuoteChar = _string.getQuoteChar local function getMatches(strings, text) if text == nil then table.sort(strings) -- ▼ ReadonlyArray.map ▼ local _newValue = table.create(#strings) local _callback = function(str, i) local formatted = if containsSpace(str) then `"{str}"` else str return { i, formatted, #formatted } end for _k, _v in strings do _newValue[_k] = _callback(_v, _k - 1, strings) end -- ▲ ReadonlyArray.map ▲ return _newValue end local textLower = string.lower(text) local textEndIndex = #text local quoteChar = getQuoteChar(text) local quoted = quoteChar ~= nil local results = {} for i = 0, #strings - 1 do local str = strings[i + 1] if quoted then str = `{quoteChar}{str}{quoteChar}` elseif containsSpace(str) then str = `"{str}"` end local part = string.sub(string.lower(str), 0, textEndIndex) if part == textLower then local _arg0 = { i, str, #str } table.insert(results, _arg0) end end table.sort(results, function(a, b) return a[2] < b[2] end) return results end local function getArgumentSuggestion(arg, textPart) local _result if arg.options.suggestions ~= nil then local _array = {} local _length = #_array local _array_1 = arg.options.suggestions table.move(_array_1, 1, #_array_1, _length + 1, _array) _result = _array else _result = {} end local suggestions = _result local singleArg = arg.kind == "single" local _result_1 if singleArg then local _result_2 = arg.type.suggestions if _result_2 ~= nil then local _condition = arg.input if _condition == nil then _condition = "" end _result_2 = _result_2(_condition, Players.LocalPlayer) end _result_1 = _result_2 else local _result_2 = arg.type.suggestions if _result_2 ~= nil then _result_2 = _result_2(arg.input or {}, Players.LocalPlayer) end _result_1 = _result_2 end local typeSuggestions = _result_1 if typeSuggestions ~= nil then for _, text in typeSuggestions do table.insert(suggestions, text) end end local errorText local input = arg.input if not arg.type.expensive and input ~= nil then local success, err = pcall(function() local transformResult = if singleArg then arg.type.transform(input, Players.LocalPlayer) else arg.type.transform(input, Players.LocalPlayer) if transformResult.ok then return nil end errorText = transformResult.value end) if not success then errorText = "Failed to transform argument" warn(err) end end local _object = { type = "argument", title = arg.options.name, } local _left = "others" local _exp = getMatches(suggestions, textPart) -- ▼ ReadonlyArray.map ▼ local _newValue = table.create(#_exp) local _callback = function(_param) local str = _param[2] return str end for _k, _v in _exp do _newValue[_k] = _callback(_v, _k - 1, _exp) end -- ▲ ReadonlyArray.map ▲ _object[_left] = _newValue _object.description = arg.options.description _object.dataType = arg.type.name local _left_1 = "optional" local _condition = arg.options.optional if _condition == nil then _condition = false end _object[_left_1] = _condition _object.error = errorText return _object end local getCommandName local function getCommandSuggestion(registry, parentPath, text) local paths = if parentPath ~= nil then registry:getChildPaths(parentPath) else registry:getRootPaths() if #paths == 0 then return nil end -- ▼ ReadonlyArray.map ▼ local _newValue = table.create(#paths) local _callback = function(path) return path:tail() end for _k, _v in paths do _newValue[_k] = _callback(_v, _k - 1, paths) end -- ▲ ReadonlyArray.map ▲ local pathNames = _newValue local sortedPaths = getMatches(pathNames, text) local firstMatch = table.remove(sortedPaths, 1) if firstMatch == nil then return nil end local firstPath = paths[firstMatch[1] + 1] local command = registry:getCommand(firstPath) if command ~= nil then local _object = { type = "command", title = getCommandName(command.options, firstPath:tail()), description = command.options.description, } local _left = "others" -- ▼ ReadonlyArray.map ▼ local _newValue_1 = table.create(#sortedPaths) local _callback_1 = function(_param) local str = _param[2] return str end for _k, _v in sortedPaths do _newValue_1[_k] = _callback_1(_v, _k - 1, sortedPaths) end -- ▲ ReadonlyArray.map ▲ _object[_left] = _newValue_1 _object.shortcuts = (command.options).shortcuts return _object end local group = registry:getGroup(firstPath) if group ~= nil then local _object = { type = "command", title = group.options.name, description = group.options.description, } local _left = "others" -- ▼ ReadonlyArray.map ▼ local _newValue_1 = table.create(#sortedPaths) local _callback_1 = function(_param) local str = _param[2] return str end for _k, _v in sortedPaths do _newValue_1[_k] = _callback_1(_v, _k - 1, sortedPaths) end -- ▲ ReadonlyArray.map ▲ _object[_left] = _newValue_1 return _object end end function getCommandName(options, input) if input == string.lower(options.name) then return options.name end for _, alias in options.aliases or {} do if input == string.lower(alias) then return alias end end return input end return { getArgumentSuggestion = getArgumentSuggestion, getCommandSuggestion = getCommandSuggestion, }