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.

CommandParameter.cs 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Diagnostics;
  3. using System.Threading.Tasks;
  4. namespace Discord.Commands
  5. {
  6. [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
  7. public class CommandParameter
  8. {
  9. private readonly TypeReader _reader;
  10. public string Name { get; }
  11. public string Summary { get; }
  12. public bool IsOptional { get; }
  13. public bool IsRemainder { get; }
  14. public bool IsMultiple { get; }
  15. public Type Type { get; }
  16. internal object DefaultValue { get; }
  17. public CommandParameter(string name, string summary, Type type, TypeReader reader, bool isOptional, bool isRemainder, bool isMultiple, object defaultValue)
  18. {
  19. Name = name;
  20. Summary = summary;
  21. Type = type;
  22. _reader = reader;
  23. IsOptional = isOptional;
  24. IsRemainder = isRemainder;
  25. IsMultiple = isMultiple;
  26. DefaultValue = defaultValue;
  27. }
  28. public async Task<TypeReaderResult> Parse(IMessage context, string input)
  29. {
  30. return await _reader.Read(context, input).ConfigureAwait(false);
  31. }
  32. public override string ToString() => Name;
  33. private string DebuggerDisplay => $"{Name}{(IsOptional ? " (Optional)" : "")}{(IsRemainder ? " (Remainder)" : "")}";
  34. }
  35. }