Allow parameterless commands to build correctly

Resolves #253
This commit is contained in:
FiniteReality
2016-08-31 13:51:09 +01:00
parent d97f90e0d0
commit 1ab763e157
2 changed files with 15 additions and 3 deletions

View File

@@ -38,7 +38,15 @@ namespace Discord.Commands
_instance = instance;
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>();

View File

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