You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandMap.cs 914 B

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
12345678910111213141516171819202122232425262728293031
  1. using System.Collections.Generic;
  2. namespace Discord.Commands
  3. {
  4. internal class CommandMap
  5. {
  6. private static readonly string[] _blankAliases = {""};
  7. private readonly CommandMapNode _root;
  8. private readonly CommandService _service;
  9. public CommandMap(CommandService service)
  10. {
  11. _service = service;
  12. _root = new CommandMapNode("");
  13. }
  14. public void AddCommand(CommandInfo command)
  15. {
  16. foreach (var text in command.Aliases)
  17. _root.AddCommand(_service, text, 0, command);
  18. }
  19. public void RemoveCommand(CommandInfo command)
  20. {
  21. foreach (var text in command.Aliases)
  22. _root.RemoveCommand(_service, text, 0, command);
  23. }
  24. public IEnumerable<CommandMatch> GetCommands(string text) => _root.GetCommands(_service, text, 0, text != "");
  25. }
  26. }