Browse Source

Allow command nodes to be separated by a configurable string

Resolves #304
pull/382/head
Christopher F 8 years ago
parent
commit
dc3be7003c
3 changed files with 5 additions and 1 deletions
  1. +2
    -0
      src/Discord.Net.Commands/CommandService.cs
  2. +2
    -0
      src/Discord.Net.Commands/CommandServiceConfig.cs
  3. +1
    -1
      src/Discord.Net.Commands/Info/CommandInfo.cs

+ 2
- 0
src/Discord.Net.Commands/CommandService.cs View File

@@ -20,6 +20,7 @@ namespace Discord.Commands
private readonly CommandMap _map; private readonly CommandMap _map;


internal readonly RunMode _defaultRunMode; internal readonly RunMode _defaultRunMode;
internal readonly string _nodeSeparator;


public IEnumerable<ModuleInfo> Modules => _moduleDefs.Select(x => x); public IEnumerable<ModuleInfo> Modules => _moduleDefs.Select(x => x);
public IEnumerable<CommandInfo> Commands => _moduleDefs.SelectMany(x => x.Commands); public IEnumerable<CommandInfo> Commands => _moduleDefs.SelectMany(x => x.Commands);
@@ -68,6 +69,7 @@ namespace Discord.Commands
[typeof(IGuildUser)] = new UserTypeReader<IGuildUser>(), [typeof(IGuildUser)] = new UserTypeReader<IGuildUser>(),
}; };
_defaultRunMode = config.DefaultRunMode; _defaultRunMode = config.DefaultRunMode;
_nodeSeparator = config.NodeSeparator;
} }


//Modules //Modules


+ 2
- 0
src/Discord.Net.Commands/CommandServiceConfig.cs View File

@@ -4,5 +4,7 @@
{ {
/// <summary> The default RunMode commands should have, if one is not specified on the Command attribute or builder. </summary> /// <summary> The default RunMode commands should have, if one is not specified on the Command attribute or builder. </summary>
public RunMode DefaultRunMode { get; set; } = RunMode.Mixed; public RunMode DefaultRunMode { get; set; } = RunMode.Mixed;
/// <summary> What character should be used between command nodes</summary>
public string NodeSeparator { get; set; } = " ";
} }
} }

+ 1
- 1
src/Discord.Net.Commands/Info/CommandInfo.cs View File

@@ -42,7 +42,6 @@ namespace Discord.Commands


// both command and module provide aliases // both command and module provide aliases
if (module.Aliases.Count > 0 && builder.Aliases.Count > 0) if (module.Aliases.Count > 0 && builder.Aliases.Count > 0)
Aliases = module.Aliases.Permutate(builder.Aliases, (first, second) => second != null ? first + " " + second : first).ToImmutableArray();
// only module provides aliases // only module provides aliases
else if (module.Aliases.Count > 0) else if (module.Aliases.Count > 0)
Aliases = module.Aliases.ToImmutableArray(); Aliases = module.Aliases.ToImmutableArray();
@@ -50,6 +49,7 @@ namespace Discord.Commands
else if (builder.Aliases.Count > 0) else if (builder.Aliases.Count > 0)
Aliases = builder.Aliases.ToImmutableArray(); Aliases = builder.Aliases.ToImmutableArray();
// neither provide aliases // neither provide aliases
Aliases = module.Aliases.Permutate(builder.Aliases, (first, second) => second != null ? first + " " + second : first).ToImmutableArray();
else else
throw new InvalidOperationException("Cannot build a command without any aliases"); throw new InvalidOperationException("Cannot build a command without any aliases");




Loading…
Cancel
Save