Implement Command Aliases
This implementation could probably be more efficient, but I opted for clarity and simplicity where possible.
This commit is contained in:
@@ -17,19 +17,21 @@ namespace Discord.Commands
|
||||
|
||||
public void AddCommand(Command command)
|
||||
{
|
||||
string text = command.Text;
|
||||
int nextSpace = NextWhitespace(text);
|
||||
string name;
|
||||
|
||||
if (nextSpace == -1)
|
||||
name = command.Text;
|
||||
else
|
||||
name = command.Text.Substring(0, nextSpace);
|
||||
|
||||
lock (this)
|
||||
foreach (string text in command.Aliases)
|
||||
{
|
||||
var nextNode = _nodes.GetOrAdd(name, x => new CommandMapNode(x));
|
||||
nextNode.AddCommand(nextSpace == -1 ? "" : text, nextSpace + 1, command);
|
||||
int nextSpace = NextWhitespace(text);
|
||||
string name;
|
||||
|
||||
if (nextSpace == -1)
|
||||
name = command.Text;
|
||||
else
|
||||
name = command.Text.Substring(0, nextSpace);
|
||||
|
||||
lock (this)
|
||||
{
|
||||
var nextNode = _nodes.GetOrAdd(name, x => new CommandMapNode(x));
|
||||
nextNode.AddCommand(nextSpace == -1 ? "" : text, nextSpace + 1, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void RemoveCommand(Command command)
|
||||
|
||||
Reference in New Issue
Block a user