From c6f871235f0aba5dc08def7a77a6595f1691343e Mon Sep 17 00:00:00 2001 From: Googie2149 Date: Thu, 29 Oct 2015 19:51:54 -0400 Subject: [PATCH] Allow multiple word commands to work again --- src/Discord.Net.Commands/CommandsPlugin.cs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Discord.Net.Commands/CommandsPlugin.cs b/src/Discord.Net.Commands/CommandsPlugin.cs index 4b78b4c34..e433e1c03 100644 --- a/src/Discord.Net.Commands/CommandsPlugin.cs +++ b/src/Discord.Net.Commands/CommandsPlugin.cs @@ -124,6 +124,25 @@ namespace Discord.Commands if (!CommandParser.Parse(msg, out cmd, out args)) return; + while (!_commands.ContainsKey(cmd)) + { + if (args.Length != 0) + { + cmd = $"{cmd} {args[0].Value}"; + CommandPart[] tempArgs = new CommandPart[args.Length - 1]; + if (args.Length - 1 > 0) + { + for (int i = 0; i < args.Length - 1; i++) + { + tempArgs[i] = args[i + 1]; + } + } + args = tempArgs; + } + else + break; + } + if (_commands.ContainsKey(cmd)) { Command comm = _commands[cmd]; @@ -146,6 +165,12 @@ namespace Discord.Commands newArgs[j] = args[j].Value; } else if (comm.MaxArgs == null && comm.MinArgs == null) + { + newArgs = new string[argCount]; + for (int j = 0; j < newArgs.Length; j++) + newArgs[j] = args[j].Value; + } + else if (comm.MaxArgs == null && comm.MinArgs != null) { newArgs = new string[argCount]; for (int j = 0; j < newArgs.Length; j++)