Table of Contents

Class RateLimitManager

Namespace
Fluxer.Net.RateLimiting
Assembly
Fluxer.Net.dll

Manages rate limit buckets for API requests with sliding window algorithm

public class RateLimitManager
Inheritance
object
RateLimitManager

Constructors

RateLimitManager(bool)

public RateLimitManager(bool enableRateLimiting = true)

Parameters

enableRateLimiting bool

Properties

ActiveBucketCount

Gets the total number of active buckets

public int ActiveBucketCount { get; }

Property Value

int

Methods

ClearAllBucketsAsync()

Clears all rate limit buckets (useful for testing)

public Task ClearAllBucketsAsync()

Returns

Task

GetBucket(RateLimitConfig, ulong?, ulong?, ulong?, ulong?, string)

Gets or creates a rate limit bucket for the given configuration and dynamic parameters

public RateLimitBucket GetBucket(RateLimitConfig config, ulong? channelId = null, ulong? guildId = null, ulong? userId = null, ulong? webhookId = null, string inviteCode = null)

Parameters

config RateLimitConfig

The rate limit configuration

channelId ulong?

Optional channel ID for channel-specific buckets

guildId ulong?

Optional guild ID for guild-specific buckets

userId ulong?

Optional user ID for user-specific buckets

webhookId ulong?

Optional webhook ID for webhook-specific buckets

inviteCode string

Optional invite code for invite-specific buckets

Returns

RateLimitBucket

The rate limit bucket

GetBucketInfoAsync(RateLimitBucket)

Gets information about a specific bucket

public Task<(int remaining, int resetMs)> GetBucketInfoAsync(RateLimitBucket bucket)

Parameters

bucket RateLimitBucket

Returns

Task<(int remaining, int resetMs)>

WaitForRateLimitAsync(RateLimitBucket)

Waits for rate limit if necessary before proceeding with request

public Task WaitForRateLimitAsync(RateLimitBucket bucket)

Parameters

bucket RateLimitBucket

The rate limit bucket to check

Returns

Task

Task that completes when request can proceed