Use aliases while removing from the CommandMap
This commit is contained in:
@@ -36,23 +36,25 @@ 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);
|
|
||||||
string name;
|
|
||||||
|
|
||||||
if (nextSpace == -1)
|
|
||||||
name = command.Text;
|
|
||||||
else
|
|
||||||
name = command.Text.Substring(0, nextSpace);
|
|
||||||
|
|
||||||
lock (this)
|
|
||||||
{
|
{
|
||||||
CommandMapNode nextNode;
|
int nextSpace = NextWhitespace(text);
|
||||||
if (_nodes.TryGetValue(name, out nextNode))
|
string name;
|
||||||
|
|
||||||
|
if (nextSpace == -1)
|
||||||
|
name = command.Text;
|
||||||
|
else
|
||||||
|
name = command.Text.Substring(0, nextSpace);
|
||||||
|
|
||||||
|
lock (this)
|
||||||
{
|
{
|
||||||
nextNode.AddCommand(nextSpace == -1 ? "" : text, nextSpace + 1, command);
|
CommandMapNode nextNode;
|
||||||
if (nextNode.IsEmpty)
|
if (_nodes.TryGetValue(name, out nextNode))
|
||||||
_nodes.TryRemove(name, out nextNode);
|
{
|
||||||
|
nextNode.RemoveCommand(nextSpace == -1 ? "" : text, nextSpace + 1, command);
|
||||||
|
if (nextNode.IsEmpty)
|
||||||
|
_nodes.TryRemove(name, out nextNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user