Browse Source

Merge cf911456a7 into 30b19de6d3

pull/193/merge
Master Kwoth GitHub 9 years ago
parent
commit
59d722d9e5
2 changed files with 10 additions and 10 deletions
  1. +6
    -6
      src/Discord.Net.Commands/Attributes/ModuleAttribute.cs
  2. +4
    -4
      src/Discord.Net.Commands/Module.cs

+ 6
- 6
src/Discord.Net.Commands/Attributes/ModuleAttribute.cs View File

@@ -7,15 +7,15 @@ namespace Discord.Commands
{
public string Prefix { get; }
public bool AutoLoad { get; set; }
public ModuleAttribute()
{
Prefix = null;
AutoLoad = true;
}
public ModuleAttribute(string prefix)
public bool AppendSpace { get; set; }

public ModuleAttribute() : this(null) { }

public ModuleAttribute(string prefix = null)
{
Prefix = prefix;
AutoLoad = true;
AppendSpace = true;
}
}
}

+ 4
- 4
src/Discord.Net.Commands/Module.cs View File

@@ -34,15 +34,15 @@ namespace Discord.Commands
Description = descriptionAttr.Text;

List<Command> commands = new List<Command>();
SearchClass(source, instance, commands, moduleAttr.Prefix ?? "");
SearchClass(source, instance, commands, moduleAttr.Prefix ?? "", moduleAttr.AppendSpace);
Commands = commands;

Preconditions = BuildPreconditions();
}

private void SearchClass(TypeInfo parentType, object instance, List<Command> commands, string groupPrefix)
private void SearchClass(TypeInfo parentType, object instance, List<Command> commands, string groupPrefix, bool appendWhitespace)
{
if (groupPrefix != "")
if (groupPrefix != "" && appendWhitespace)
groupPrefix += " ";
foreach (var method in parentType.DeclaredMethods)
{
@@ -60,7 +60,7 @@ namespace Discord.Commands
nextGroupPrefix = groupPrefix + groupAttrib.Prefix ?? type.Name;
else
nextGroupPrefix = groupPrefix;
SearchClass(type, ReflectionUtils.CreateObject(type, Service), commands, nextGroupPrefix);
SearchClass(type, ReflectionUtils.CreateObject(type, Service), commands, nextGroupPrefix, appendWhitespace);
}
}
}


Loading…
Cancel
Save