Merge pull request #260 from FiniteReality/dev

Allow parameterless commands to build correctly
This commit is contained in:
RogueException
2016-09-01 13:34:17 -03:00
committed by GitHub
2 changed files with 14 additions and 6 deletions

View File

@@ -38,7 +38,15 @@ namespace Discord.Commands
_instance = instance; _instance = instance;
Name = source.Name; Name = source.Name;
Text = groupPrefix + attribute.Text;
if (attribute.Text == null)
Text = groupPrefix;
if (groupPrefix != "")
groupPrefix += " ";
if (attribute.Text != null)
Text = groupPrefix + attribute.Text;
var aliasesBuilder = ImmutableArray.CreateBuilder<string>(); var aliasesBuilder = ImmutableArray.CreateBuilder<string>();

View File

@@ -48,8 +48,6 @@ namespace Discord.Commands
private void SearchClass(TypeInfo parentType, object instance, List<Command> commands, string groupPrefix, IDependencyMap dependencyMap) private void SearchClass(TypeInfo parentType, object instance, List<Command> commands, string groupPrefix, IDependencyMap dependencyMap)
{ {
if (groupPrefix != "")
groupPrefix += " ";
foreach (var method in parentType.DeclaredMethods) foreach (var method in parentType.DeclaredMethods)
{ {
var cmdAttr = method.GetCustomAttribute<CommandAttribute>(); var cmdAttr = method.GetCustomAttribute<CommandAttribute>();
@@ -62,10 +60,12 @@ namespace Discord.Commands
if (groupAttrib != null) if (groupAttrib != null)
{ {
string nextGroupPrefix; string nextGroupPrefix;
if (groupAttrib.Prefix != null)
nextGroupPrefix = groupPrefix + groupAttrib.Prefix ?? type.Name; if (groupPrefix != "")
nextGroupPrefix = groupPrefix + " " + (groupAttrib.Prefix ?? type.Name.ToLowerInvariant());
else else
nextGroupPrefix = groupPrefix; nextGroupPrefix = groupAttrib.Prefix ?? type.Name.ToLowerInvariant();
SearchClass(type, ReflectionUtils.CreateObject(type, Service, dependencyMap), commands, nextGroupPrefix, dependencyMap); SearchClass(type, ReflectionUtils.CreateObject(type, Service, dependencyMap), commands, nextGroupPrefix, dependencyMap);
} }
} }