From dc3be7003ca9b318a540994d6a17b2ecd9d5808f Mon Sep 17 00:00:00 2001 From: Christopher F Date: Sat, 26 Nov 2016 15:28:20 -0500 Subject: [PATCH] Allow command nodes to be separated by a configurable string Resolves #304 --- src/Discord.Net.Commands/CommandService.cs | 2 ++ src/Discord.Net.Commands/CommandServiceConfig.cs | 2 ++ src/Discord.Net.Commands/Info/CommandInfo.cs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index 9420476d5..c52fca261 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -20,6 +20,7 @@ namespace Discord.Commands private readonly CommandMap _map; internal readonly RunMode _defaultRunMode; + internal readonly string _nodeSeparator; public IEnumerable Modules => _moduleDefs.Select(x => x); public IEnumerable Commands => _moduleDefs.SelectMany(x => x.Commands); @@ -68,6 +69,7 @@ namespace Discord.Commands [typeof(IGuildUser)] = new UserTypeReader(), }; _defaultRunMode = config.DefaultRunMode; + _nodeSeparator = config.NodeSeparator; } //Modules diff --git a/src/Discord.Net.Commands/CommandServiceConfig.cs b/src/Discord.Net.Commands/CommandServiceConfig.cs index 97c98a54c..66ddade10 100644 --- a/src/Discord.Net.Commands/CommandServiceConfig.cs +++ b/src/Discord.Net.Commands/CommandServiceConfig.cs @@ -4,5 +4,7 @@ { /// The default RunMode commands should have, if one is not specified on the Command attribute or builder. public RunMode DefaultRunMode { get; set; } = RunMode.Mixed; + /// What character should be used between command nodes + public string NodeSeparator { get; set; } = " "; } } diff --git a/src/Discord.Net.Commands/Info/CommandInfo.cs b/src/Discord.Net.Commands/Info/CommandInfo.cs index 2ca8b1651..4d862da0c 100644 --- a/src/Discord.Net.Commands/Info/CommandInfo.cs +++ b/src/Discord.Net.Commands/Info/CommandInfo.cs @@ -42,7 +42,6 @@ namespace Discord.Commands // both command and module provide aliases 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 else if (module.Aliases.Count > 0) Aliases = module.Aliases.ToImmutableArray(); @@ -50,6 +49,7 @@ namespace Discord.Commands else if (builder.Aliases.Count > 0) Aliases = builder.Aliases.ToImmutableArray(); // neither provide aliases + Aliases = module.Aliases.Permutate(builder.Aliases, (first, second) => second != null ? first + " " + second : first).ToImmutableArray(); else throw new InvalidOperationException("Cannot build a command without any aliases");