Implement configurable command node separators
This fixes #304 over foxbot's PR for the same issue.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user