# discord.js-rate-limiter

> Rate limiter for discord.js.

Latest version **1.3.2** (published 2022-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install discord.js-rate-limiter
pnpm add discord.js-rate-limiter
yarn add discord.js-rate-limiter
bun add discord.js-rate-limiter
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2022-02-08 |
| First published | 2020-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 1 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Kevin Novak |
| Maintainers | kevinnovak |
| Keywords | cooldown, discord, discord.js, extension, extensions, language, limit, limiter, rate, throttle, throttling, util, utilities, utility |

## Links

- npm: https://www.npmjs.com/package/discord.js-rate-limiter
- Repository: https://github.com/KevinNovak/discord.js-Rate-Limiter
- npm.io page: https://npm.io/package/discord.js-rate-limiter

## Dependencies (1)

- [limiter](https://npm.io/package/limiter.md) 2.1.0

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.3.2 (latest) — 2022-02-08
- 1.3.1 — 2022-01-08
- 1.3.0 — 2022-01-08
- 1.2.3 — 2021-10-11
- 1.2.2 — 2021-08-19
- 1.2.1 — 2021-08-19
- 1.2.0 — 2021-08-07
- 1.1.0 — 2021-07-02
- 1.0.7 — 2021-04-06
- 1.0.6 — 2021-04-03
- 1.0.5 — 2020-12-30
- 1.0.4 — 2020-12-28
- 1.0.3 — 2020-11-29
- 1.0.2 — 2020-11-24
- 1.0.1 — 2020-11-24
- … 1 more at https://npm.io/package/discord.js-rate-limiter/versions

## README

# discord.js-Rate-Limiter

[![NPM Version](https://img.shields.io/npm/v/discord.js-rate-limiter.svg?maxAge=3600)](https://www.npmjs.com/package/discord.js-rate-limiter)
[![discord.js Version](https://img.shields.io/npm/dependency-version/discord.js-rate-limiter/peer/discord.js)](https://discord.js.org/)
[![Downloads](https://img.shields.io/npm/dt/discord.js-rate-limiter.svg?maxAge=3600)](https://www.npmjs.com/package/discord.js-rate-limiter)

Rate limiter for [discord.js](https://github.com/discordjs/discord.js/).

## Installation

`npm install discord.js-rate-limiter`

## Importing

```typescript
import { RateLimiter } from 'discord.js-rate-limiter';
```

## Example Usage

```typescript
import { Client, Intents } from 'discord.js';
import { RateLimiter } from 'discord.js-rate-limiter';

let Config = require('../config/config.json');

// Allows 1 command every 2 seconds
let rateLimiter = new RateLimiter(1, 2000);
let client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

client.on('ready', () => {
    console.log(`Logged in as '${client.user.tag}'!`);
});

client.on('messageCreate', async msg => {
    // Don't respond to bots
    if (msg.author.bot) {
        return;
    }

    if (msg.content === 'test') {
        // Check if user is rate limited
        let limited = rateLimiter.take(msg.author.id);
        if (limited) {
            // Send back a message (or you may want to just drop the request)
            await msg.channel.send(`You're doing that do often, please try again later!`);
            return;
        }

        // Run test command
        await msg.channel.send(`Test command ran!`);
        return;
    }
});

client.login(Config.token);
```

![Example](https://i.imgur.com/9HB4Mmo.png)

---
_Source: https://npm.io/package/discord.js-rate-limiter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
