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.

RuntimeResult.cs 777 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Text;
  5. namespace Discord.Commands
  6. {
  7. [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
  8. public abstract class RuntimeResult : IResult
  9. {
  10. protected RuntimeResult(CommandError? error, string reason)
  11. {
  12. Error = error;
  13. Reason = reason;
  14. }
  15. public CommandError? Error { get; }
  16. public string Reason { get; }
  17. public bool IsSuccess => !Error.HasValue;
  18. string IResult.ErrorReason => Reason;
  19. public override string ToString() => Reason ?? (IsSuccess ? "Successful" : "Unsuccessful");
  20. private string DebuggerDisplay => IsSuccess ? $"Success: {Reason ?? "No Reason"}" : $"{Error}: {Reason}";
  21. }
  22. }