/// <summary> /// Checks if the ratelimit is valid and/or is expired. /// </summary> /// <param name="rl">The instance that is being checked.</param> /// <param name="result">Information about the ratelimit</param> /// <returns>Whether the instance is being ratelimited</returns> public static bool IsRatelimited(Ratelimit rl, out RatelimitResult result) { var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); if ((rl.Global <= 0 || rl.Remaining <= 0) && now < rl.Reset) { result = new RatelimitResult((int)(rl.Reset - now)); return(true); } result = default; return(false); }
/// <summary> /// Checks if the current ratelimit is valid and/or is expired. /// </summary> /// <returns>Whether the current instance is being ratelimited</returns> /// <param name="result">Information about the ratelimit</param> public bool IsRatelimited(out RatelimitResult result) { return(IsRatelimited(this, out result)); }