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.

RequestOptions.cs 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Threading;
  2. namespace Discord
  3. {
  4. public class RequestOptions
  5. {
  6. public static RequestOptions Default => new RequestOptions();
  7. /// <summary>
  8. /// The max time, in milliseconds, to wait for this request to complete. If null, a request will not time out.
  9. /// If a rate limit has been triggered for this request's bucket and will not be unpaused in time, this request will fail immediately.
  10. /// </summary>
  11. public int? Timeout { get; set; }
  12. public CancellationToken CancelToken { get; set; } = CancellationToken.None;
  13. public RetryMode? RetryMode { get; set; }
  14. public bool HeaderOnly { get; internal set; }
  15. /// <summary>
  16. /// Should this request bypass the ratelimit buckets? This option should be used sparingly, and when used, should be coupled with your own
  17. /// delays between requests, to avoid encountering 429 errors.
  18. /// </summary>
  19. public bool BypassBuckets { get; set; }
  20. /// <summary>
  21. /// The reason for this action in the guild's audit log
  22. /// </summary>
  23. public string AuditLogReason { get; set; }
  24. internal bool IgnoreState { get; set; }
  25. internal string BucketId { get; set; }
  26. internal bool IsClientBucket { get; set; }
  27. internal static RequestOptions CreateOrClone(RequestOptions options)
  28. {
  29. if (options == null)
  30. return new RequestOptions();
  31. else
  32. return options.Clone();
  33. }
  34. public RequestOptions()
  35. {
  36. Timeout = DiscordConfig.DefaultRequestTimeout;
  37. }
  38. public RequestOptions Clone() => MemberwiseClone() as RequestOptions;
  39. }
  40. }