Implement configurable command node separators

This fixes #304 over foxbot's PR for the same issue.
This commit is contained in:
FiniteReality
2016-12-09 10:31:57 +00:00
parent 803b65212e
commit 70d30efb94
6 changed files with 65 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);
@@ -74,6 +75,8 @@ namespace Discord.Commands
};
_caseSensitive = config.CaseSensitiveCommands;
_defaultRunMode = config.DefaultRunMode;
_splitCharacter = config.CommandSplitCharacter;
}
//Modules
@@ -143,7 +146,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);
@@ -187,7 +190,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)
{
@@ -228,7 +231,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);