@seedcord/rate-limiter
v0.1.8
Published
Rate limiting and key building for seedcord bots
Maintainers
Readme
About
@seedcord/rate-limiter gives you MemoryRateLimiter and buildKey. Each transport constructs one in its Seedcord constructor and assigns it to core.rateLimiter. The Cooldown gate reads it from there. A handler gets the same instance from this.core.rateLimiter.
MemoryRateLimiter counts in one process, so it resets on restart and stays per-isolate on serverless. Pass your own Store<'charge'> as config.store to keep the counts across restarts and isolates.
Until v1.0.0, minor versions can break.
Installation
Your transport already re-exports this.
pnpm add @seedcord/rate-limiterUsage
buildKey joins a prefix and its parts with :, substituting global for a null part, so two features never collide on one user id:
import { buildKey, MemoryRateLimiter } from '@seedcord/rate-limiter';
const limiter = new MemoryRateLimiter();
const key = buildKey('daily', interaction.user.id);The Cooldown gate covers the common case. Call this.core.rateLimiter from a handler when the gate has no option for the window you want.
