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 963 B

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