cooldown.djs

1.0.1 • Public • Published

cooldown - Rate limit everything.

Simple tool to make rate limits. Cooldown.djs is a packaged promise setTimeout.

const Cooldown = require('cooldown.djs');

(async () => {
    await Cooldown('user-0001', 5000);
    /* Adding variable "user-0001" to waiting list with a 5 second interval. */

    var Hold = await Cooldown('user-0001');
    /* Checking if the variable "user-0001" is being awaited. */
    // -> Promise { Boolean }

    if (!Hold) {
        /* Content to be executed if the item isn't being awaited. */
    };
})();

You can also use it in your Discord API based apps.

run: async ( ... ) => {
    if (!Cooldown(interaction.user.id)) {
        // ... Run your normal command.
    } else interaction.reply('You need to wait before using this command again.');
    /* Display rate limit warning. */
};

Package Sidebar

Install

npm i cooldown.djs

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

1.41 kB

Total Files

3

Last publish

Collaborators

  • faon