Merge pull request #412 from FiniteReality/issue/304-v2

Implement configurable command node separators
This commit is contained in:
RogueException
2016-12-16 15:38:27 -04:00
committed by GitHub
6 changed files with 64 additions and 34 deletions

View File

@@ -22,6 +22,7 @@ namespace Discord.Commands
internal readonly bool _caseSensitive;
internal readonly RunMode _defaultRunMode;
internal readonly char _splitCharacter;
public IEnumerable<ModuleInfo> Modules => _moduleDefs.Select(x => x);
public IEnumerable<CommandInfo> Commands => _moduleDefs.SelectMany(x => x.Commands);
@@ -60,6 +61,7 @@ namespace Discord.Commands
_caseSensitive = config.CaseSensitiveCommands;
_defaultRunMode = config.DefaultRunMode;
_splitCharacter = config.CommandSplitCharacter;
}
//Modules
@@ -129,7 +131,7 @@ namespace Discord.Commands
_moduleDefs.Add(module);
foreach (var command in module.Commands)
_map.AddCommand(command);
_map.AddCommand(command, this);
foreach (var submodule in module.Submodules)
LoadModuleInternal(submodule);
@@ -173,7 +175,7 @@ namespace Discord.Commands
return false;
foreach (var cmd in module.Commands)
_map.RemoveCommand(cmd);
_map.RemoveCommand(cmd, this);
foreach (var submodule in module.Submodules)
{
@@ -214,7 +216,7 @@ namespace Discord.Commands
public SearchResult Search(CommandContext context, string input)
{
string searchInput = _caseSensitive ? input : input.ToLowerInvariant();
var matches = _map.GetCommands(searchInput).OrderByDescending(x => x.Priority).ToImmutableArray();
var matches = _map.GetCommands(searchInput, this).OrderByDescending(x => x.Priority).ToImmutableArray();
if (matches.Length > 0)
return SearchResult.FromSuccess(input, matches);