using System.Threading;
namespace Discord
{
///
/// Represents options that should be used when sending a request.
///
public class RequestOptions
{
///
/// Creates a new class with its default settings.
///
public static RequestOptions Default => new RequestOptions();
///
/// Gets or sets the maximum time to wait for for this request to complete.
///
///
/// Gets or set the max time, in milliseconds, to wait for for this request to complete. If
/// null, a request will not time out. If a rate limit has been triggered for this request's bucket
/// and will not be unpaused in time, this request will fail immediately.
///
///
/// A in milliseconds for when the request times out.
///
public int? Timeout { get; set; }
///
/// Gets or sets the cancellation token for this request.
///
///
/// A for this request.
///
public CancellationToken CancelToken { get; set; } = CancellationToken.None;
///
/// Gets or sets the retry behavior when the request fails.
///
public RetryMode? RetryMode { get; set; }
public bool HeaderOnly { get; internal set; }
///
/// Gets or sets the reason for this action in the guild's audit log.
///
///
/// Gets or sets the reason that will be written to the guild's audit log if applicable. This may not apply
/// to all actions.
///
public string AuditLogReason { get; set; }
///
/// Gets or sets whether or not this request should use the system
/// clock for rate-limiting. Defaults to true.
///
///
/// This property can also be set in .
///
/// On a per-request basis, the system clock should only be disabled
/// when millisecond precision is especially important, and the
/// hosting system is known to have a desynced clock.
///
public bool? UseSystemClock { get; set; }
internal bool IgnoreState { get; set; }
internal string BucketId { get; set; }
internal bool IsClientBucket { get; set; }
internal bool IsReactionBucket { get; set; }
internal static RequestOptions CreateOrClone(RequestOptions options)
{
if (options == null)
return new RequestOptions();
else
return options.Clone();
}
///
/// Initializes a new class with the default request timeout set in
/// .
///
public RequestOptions()
{
Timeout = DiscordConfig.DefaultRequestTimeout;
}
public RequestOptions Clone() => MemberwiseClone() as RequestOptions;
}
}