Use aliases while removing from the CommandMap

This commit is contained in:
FiniteReality
2016-08-27 19:44:53 +01:00
parent 95cf63243d
commit 94dc123e8d

View File

@@ -36,7 +36,8 @@ namespace Discord.Commands
} }
public void RemoveCommand(Command command) public void RemoveCommand(Command command)
{ {
string text = command.Text; foreach (string text in command.Aliases)
{
int nextSpace = NextWhitespace(text); int nextSpace = NextWhitespace(text);
string name; string name;
@@ -50,12 +51,13 @@ namespace Discord.Commands
CommandMapNode nextNode; CommandMapNode nextNode;
if (_nodes.TryGetValue(name, out nextNode)) if (_nodes.TryGetValue(name, out nextNode))
{ {
nextNode.AddCommand(nextSpace == -1 ? "" : text, nextSpace + 1, command); nextNode.RemoveCommand(nextSpace == -1 ? "" : text, nextSpace + 1, command);
if (nextNode.IsEmpty) if (nextNode.IsEmpty)
_nodes.TryRemove(name, out nextNode); _nodes.TryRemove(name, out nextNode);
} }
} }
} }
}
public IEnumerable<Command> GetCommands(string text) public IEnumerable<Command> GetCommands(string text)
{ {