From 94dc123e8d6d16d05ffeb4964933f5e2ff02f750 Mon Sep 17 00:00:00 2001 From: FiniteReality Date: Sat, 27 Aug 2016 19:44:53 +0100 Subject: [PATCH] Use aliases while removing from the CommandMap --- src/Discord.Net.Commands/Map/CommandMap.cs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Discord.Net.Commands/Map/CommandMap.cs b/src/Discord.Net.Commands/Map/CommandMap.cs index ac0a4b7fc..f75a0f12f 100644 --- a/src/Discord.Net.Commands/Map/CommandMap.cs +++ b/src/Discord.Net.Commands/Map/CommandMap.cs @@ -36,23 +36,25 @@ namespace Discord.Commands } public void RemoveCommand(Command command) { - string text = command.Text; - int nextSpace = NextWhitespace(text); - string name; + foreach (string text in command.Aliases) + { + int nextSpace = NextWhitespace(text); + string name; - if (nextSpace == -1) - name = command.Text; - else - name = command.Text.Substring(0, nextSpace); + if (nextSpace == -1) + name = command.Text; + else + name = command.Text.Substring(0, nextSpace); - lock (this) - { - CommandMapNode nextNode; - if (_nodes.TryGetValue(name, out nextNode)) + lock (this) { - nextNode.AddCommand(nextSpace == -1 ? "" : text, nextSpace + 1, command); - if (nextNode.IsEmpty) - _nodes.TryRemove(name, out nextNode); + CommandMapNode nextNode; + if (_nodes.TryGetValue(name, out nextNode)) + { + nextNode.RemoveCommand(nextSpace == -1 ? "" : text, nextSpace + 1, command); + if (nextNode.IsEmpty) + _nodes.TryRemove(name, out nextNode); + } } } }