Implement configurable command node separators
This fixes #304 over foxbot's PR for the same issue.
This commit is contained in:
@@ -44,7 +44,7 @@ namespace Discord.Commands
|
||||
|
||||
// both command and module provide aliases
|
||||
if (module.Aliases.Count > 0 && builder.Aliases.Count > 0)
|
||||
Aliases = module.Aliases.Permutate(builder.Aliases, (first, second) => second != null ? first + " " + second : first).Select(x => service._caseSensitive ? x : x.ToLowerInvariant()).ToImmutableArray();
|
||||
Aliases = module.Aliases.Permutate(builder.Aliases, (first, second) => second != null ? first + service._splitCharacter + second : first).Select(x => service._caseSensitive ? x : x.ToLowerInvariant()).ToImmutableArray();
|
||||
// only module provides aliases
|
||||
else if (module.Aliases.Count > 0)
|
||||
Aliases = module.Aliases.Select(x => service._caseSensitive ? x : x.ToLowerInvariant()).ToImmutableArray();
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace Discord.Commands
|
||||
Remarks = builder.Remarks;
|
||||
Parent = parent;
|
||||
|
||||
Aliases = BuildAliases(builder).ToImmutableArray();
|
||||
Aliases = BuildAliases(builder, service).ToImmutableArray();
|
||||
Commands = builder.Commands.Select(x => x.Build(this, service));
|
||||
Preconditions = BuildPreconditions(builder).ToImmutableArray();
|
||||
|
||||
Submodules = BuildSubmodules(builder, service).ToImmutableArray();
|
||||
}
|
||||
|
||||
private static IEnumerable<string> BuildAliases(ModuleBuilder builder)
|
||||
private static IEnumerable<string> BuildAliases(ModuleBuilder builder, CommandService service)
|
||||
{
|
||||
IEnumerable<string> result = null;
|
||||
|
||||
@@ -60,9 +60,9 @@ namespace Discord.Commands
|
||||
result = level.Aliases.ToList(); //create a shallow copy so we don't overwrite the builder unexpectedly
|
||||
}
|
||||
else if (result.Count() > level.Aliases.Count)
|
||||
result = result.Permutate(level.Aliases, (first, second) => first + " " + second);
|
||||
result = result.Permutate(level.Aliases, (first, second) => first + service._splitCharacter + second);
|
||||
else
|
||||
result = level.Aliases.Permutate(result, (second, first) => first + " " + second);
|
||||
result = level.Aliases.Permutate(result, (second, first) => first + service._splitCharacter + second);
|
||||
}
|
||||
|
||||
if (result == null) //there were no aliases; default to an empty list
|
||||
|
||||
Reference in New Issue
Block a user