npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-webhook-manager

v0.0.7

Published

A Discord Webhook Manager for Node.JS - Easily customisable webhook settings with webhook rate limits

Downloads

20

Readme

Webhook Manager

Build Status GitHub code size in bytes GitHub issues GitHub

A lightweight Discord Webhook Manager for Node.JS - Easily customisable webhook settings with webhook rate limits and let the manager send the webhooks for you!

Installation

Node 8+ is required for the webhook manager to work. Previous versions of Node.JS may work, however they will not be supported. To install, run this in your project folder:

NPM

npm i discord-webhook-manager

Yarn

yarn add discord-webhook-manager

Bower

bower install discord-webhook-manager

Usage

const WebhookManager = require('discord-webhook-manager');

const webhook1 = new WebhookManager(webhookID, webhookToken[, format[, interval[, joinInputLengths]]]);
webhook1.addToQueue('Message goes here')

webhookID: string - Webhook ID

webhookToken: string - Webhook Token

format: object (optional) - The way the webhook should be sent, this should be in the Discord webhook format. Use 'text' as a placeholder for adding messages to the queue. Default:

{
  content: 'text'
}

interval: number (optional) - Interval at which webhooks should be sent at in milliseconds, e.g. 5000 would be 5 seconds. Default: 2000

joinInputLengths: number (optional) - Maximum character count of joined messages (especially useful for logs). If you don't want them joined, leave at 0. Default: 0

Properties/Functions

WebhookManager.url

webhook1.url: string - URL of selected Webhook

WebhookManager.format

webhook1.format: object - Format of webhook message as set in format parameter

WebhookManager.interval

webhook1.interval: number - Interval at which webhooks are sent in milliseconds

WebhookManager.joinInputLengths

webhook1.joinInputLengths: number - Maximum length of joined messages, or no joined messages if 0

WebhookManager.queue

webhook1.queue: string[] - Array of messages in the queue

WebhookManager.rateLimiter

webhook1.rateLimiter: Date[] - Array of ISO8601 timestamps of sent webhooks, used for rate limiting webhook requests

WebhookManager.enabled

webhook1.enabled: boolean - Whether the webhook is running or not

WebhookManager.addToQueue(message: string)

webhook1.addToQueue('Message here'): string[] - Adds a message to the queue. Returns the queue

WebhookManager.emptyQueue()

webhook1.emptyQueue(): string[] - Removes everything in the queue. Returns the empty queue

WebhookManager.resetRateLimit()

webhook1.resetRateLimit(): Date[] - Resets the rate limit. Returns the empty rate limit

WebhookManager.updateWebhook(webhookID: string, webhookToken: string)

webhook1.updateWebhook('649305310778884106', 'TYCRyGQbze-UTFzlUgOmP6FgQK_0LnL5axCku06fTDr-CyI1VytbcDRveDl0frbA_PiM0'): string - Updates the webhook URL. Returns the new Webhook URL (don't try using this, it doesn't exist)

WebhookManager.pauseWebhookSending()

webhook1.pauseWebhookSending(): boolean - Pause webhook sending. Returns the enabled status

WebhookManager.startWebhookSending()

webhook1.startWebhookSending(): boolean - Start/resume webhook sending. Returns the enabled status

WebhookManager.stopWebhookSending()

webhook1.stopWebhookSending(): boolean - End webhook sending and clear the queue. Returns the enabled status

Events

error

Emits when an error occurs with the webhook sending

webhook1.on('error', (errorMessage: string, error: Error) => {
  console.error(error)
  console.error(errorMessage)
  // Do something to resolve the error
});