Browse Source

Merge pull request #260 from FiniteReality/dev

Allow parameterless commands to build correctly
tags/1.0-rc
RogueException GitHub 8 years ago
parent
commit
c26dbc2f0f
2 changed files with 14 additions and 6 deletions
  1. +9
    -1
      src/Discord.Net.Commands/Command.cs
  2. +5
    -5
      src/Discord.Net.Commands/Module.cs

+ 9
- 1
src/Discord.Net.Commands/Command.cs 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>();



+ 5
- 5
src/Discord.Net.Commands/Module.cs 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>();
@@ -62,10 +60,12 @@ namespace Discord.Commands
if (groupAttrib != null)
{
string nextGroupPrefix;
if (groupAttrib.Prefix != null)
nextGroupPrefix = groupPrefix + groupAttrib.Prefix ?? type.Name;

if (groupPrefix != "")
nextGroupPrefix = groupPrefix + " " + (groupAttrib.Prefix ?? type.Name.ToLowerInvariant());
else
nextGroupPrefix = groupPrefix;
nextGroupPrefix = groupAttrib.Prefix ?? type.Name.ToLowerInvariant();

SearchClass(type, ReflectionUtils.CreateObject(type, Service, dependencyMap), commands, nextGroupPrefix, dependencyMap);
}
}


Loading…
Cancel
Save