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

blwebhooks

v4.0.0

Published

Webhook Vote Reciever For Lists Such As top.gg, InfinityBotList and Many More To Come!

Downloads

670

Readme

Known Vulnerabilities npm version dependencies Status install size DeepScan grade blwebhooks ts

NPM

BLWebhooks, The Next Gen Vote Hooks!

Table of Contents

Installation

Need Any Help Setting It Up? Join Our Support Server. It's intended to be used with discord.js v14.

BLWebhooks fully supports external and discord.js internal sharding, make sure to enable the Sharded Client Option.

BLWebhooks is maintained and supported by the JMServices Team.

NPM (recommended)

# Stable
npm i --save blwebhooks

# Nightly Builds
npm i --save blwebhooks@nightly

Yarn

# Stable
yarn add blwebhooks

# Nightly Builds
yarn add blwebhooks@nightly

Supported Libraries

| Name | Features | | ------------------------------------------------------ | ------------------------------------------ | | discord.js | DATABASE, EXPRESS, HOOKS, SECURITY | | Eris | EXPRESS, HOOKS, SECURITY |

Supported Lists

| Name | Features | UserID | BotID | userName | Event Name | | --------------- | ------------------- | ------ | ----- | -------- | ----------- | | top.gg | DATABASE, HOOKS | true | true | false | topgg-voted | | InfinityBotList | DATABASE, HOOKS | true | true | false | IBL-voted | | VoidBots | DATABASE, HOOKS | true | true | false | VB-voted | | DiscordLabs | DATABASE, HOOKS | true | true | false | DL-voted | | Blist | DATABASE, HOOKS | true | true | false | BLT-voted | | DiscordBots.co | DATABASE, HOOKS | true | true | false | DBC-voted | | ParadiseBotList | DATABASE, HOOKS | true | true | true | PBL-voted |

Future Lists

| Name | Features | ETA | | ------ | ------------------- | --- | | Botrix | DATABASE, HOOKS | N/A |

Usage

Import the lib via ES6 or commonJS modules

// ES6
import * as blwebhooks from "blwebhooks";
// or commonJS
const blwebhooks = require("blwebhooks");

With discord.js

const { Client } = require("discord.js");
const client = new Client({
  intents: []
});

const { WebhooksManager } = require("blwebhooks");

const voteClient = new WebhooksManager(client, 80, {
  database: "none", // mongoose or sqlite3

  protocol: "discordjs", // Define the discord client

  string: "mongodb://", // Only Use This If The Database Is Set To Mongoose

  extra: {
    extraLogging: false, // This will enable extraLogging {Debugging}

    extraProtection: true, // Leave Enabled Unless Using Small Amount Of RAM

    proxyTrust: false, // Enable this if your behind a proxy, Heroku.
  },
});

// Attach to client
client.voteManager = voteClient;

With Eris

const Eris = require("eris");

var bot = new Eris("BOT_TOKEN");
// Replace BOT_TOKEN with your bot account's token

bot.on("ready", () => {
  // When the bot is ready
  console.log("Ready!"); // Log "Ready!"
});

const { WebhooksManager } = require("blwebhooks");

const voteClient = new WebhooksManager(bot, 80, {
  database: "none", // mongoose or sqlite3

  protocol: "eris", // Define the discord client

  string: "mongodb://", // Only Use This If The Database Is Set To Mongoose

  extra: {
    extraLogging: false, // This will enable extraLogging {Debugging}

    extraProtection: true, // Leave Enabled Unless Using Small Amount Of RAM

    proxyTrust: false, // Enable this if your behind a proxy, Heroku.
  },
});

// Attach to client
bot.voteManager = voteClient;

bot.connect(); // Get the bot to connect to Discord

Vote Storage

// Set the vote storage in the voteClient
const voteClient = new WebhooksManager(client, 80, {
  database: "mongoose", // mongoose or sqlite
  string: "mongooseDB-URL",
  extra: {
    extraLogging: false,
    extraProtection: true,
    proxyTrust: false,
  },
});

For usage on pulling data see the Database Vote Section.

Extended Security

// You can enable this via the voteClient
const voteClient = new WebhooksManager(client, 80, {
  database: "mongoose",
  string: "mongooseDB-URL",
  extra: {
    extraLogging: false,
    extraProtection: true, // Enable this here
    proxyTrust: false,
  },
});

Proxy Trust

// Enable this in the voteClient
const voteClient = new WebhooksManager(client, 80, {
  database: "mongoose",
  string: "mongooseDB-URL",
  extra: {
    extraLogging: false,
    extraProtection: true,
    proxyTrust: true, // Enable it here
  },
});

Test Events

// Emit a test event to test your Voted Event
voteClient.testVote(userID, botID);

Vote Hooks

TopGG Vote Hooks:

// This will listen to votes from top.gg, the url is the end not
// including the / and auth is the webhook auth. You can enable and
// disable using true or false at the end
client.voteManager.topggVoteHook(url, auth, true);

// This code will run after a new vote was received from top.gg
client.on("topgg-voted", async function (userID, botID, type) {
  console.log(userID);
});

InfinityBotList Vote Hooks:

// This will listen to votes from InfinityBotList, the url is the end not
// including the / and auth is the webhook auth. You can enable and
// disable using true or false at the end
client.voteManager.IBLVoteHook(url, auth, true);

// This code will run after a new vote was received from InfinityBotList
client.on("IBL-voted", async function (userID, botID, type) {
  console.log(userID);
});

VoidBots Vote Hooks:

// This will listen to votes from VoidBots, the url is the end not
// including the / and auth is the webhook auth. You can enable and
// disable using true or false at the end
client.voteManager.VoidBotsVoteHook(url, auth, true);

// This code will run after a new vote was received from VoidBots
client.on("VB-voted", async function (userID, botID) {
  console.log(userID + " Voted For " + botID);
});

DiscordLabs Vote Hooks:

// This will listen to votes from DiscordLabs, the url is the end not
// including the / and auth is the webhook auth. You can enable and
// disable using true or false at the end
client.voteManager.DiscordLabsVoteHook(url, auth, true);

// This code will run after a new vote was received from DiscordLabs
client.on("DL-voted", async function (userID, botID, wasTest) {
  console.log(`${userID} Voted For ${botID}. Was Test: ${wasTest}`);
});

Botrix Vote Hooks:

// This will listen to votes from Botrix, the url is the end not
// including the / and auth is the webhook auth. You can enable and
// disable using true or false at the end
client.voteManager.BotrixVoteHook(url, auth, true);

// This code will run after a new vote was received from Botrix
client.on("BTR-voted", async function (userID, botID) {
  console.log(`${userID} Voted For ${botID}.`);
});

BList Vote Hooks:

// This will listen to votes from BList, the url is the end not
// including the / and auth is the webhook auth. You can enable and
// disable using true or false at the end
client.voteManager.BListVoteHook(url, auth, true);

// This code will run after a new vote was received from BList
client.on("BLT-voted", async function (userID, botID) {
  console.log(`${userID} Voted.`);
});

DiscordBots.co Vote Hooks:

// This will listen to votes from BList, the url is the end not
// including the / and auth is the webhook auth. You can enable and
// disable using true or false at the end
client.voteManager.DBCVoteHook(url, auth, true);

// This code will run after a new vote was received from BList
client.on("DBC-voted", async function (userID, botID) {
  console.log(`${userID} Voted.`);
});

ParadiseBotList Vote Hooks:

// This will listen to votes from BList, the url is the end not
// including the / and auth is the webhook auth. You can enable and
// disable using true or false at the end
client.voteManager.PBLVoteHook(url, auth, true);

// This code will run after a new vote was received from BList
client.on("PBL-voted", async function (userID, botID, userName) {
  console.log(`${userName} (${userID}) Voted For <#${botID}>`);
});

Events

Global Voted Event

// This will run after any vote has been received, use this if you don't want seprate events for each list
client.on("vote", async function (userID, botID, List) {
  console.log(`${userID} Voted For ${botID} on ${List}`);
});

Vote Expired Event

// This will run after the vote expires, this will be different for each list
client.on("vote-expired", async function (userID, botID, List) {
  console.log(userID);
});

Error Event

// This code will run in the event of a error, normally it will just console.log the error but you can add custom error events here
client.on("webhookError", async function (error) {
  console.log(userID);
});

Vote Database

The vote Database feature will save the total votes a User had made for your bot / server, it will add all the vote in a database and the methods below show you how to set it up and pull data.

discord.js example

// The DB can be set to either mongo, sqlite
// Only set the string if using the mongoose db
voteClient.setStroage(DB, String);

// MongooseDB Example (recommended)
voteClient.setStroage("mongoose", "mongodb://localhost/my_database");

// SQLITE Example
voteClient.setStroage("sqlite3");

Pulling User Votes

voteClient.getVotes(userID, option);

Options:

  • daily - Get Daily Votes
  • weekly - Get Weekly Votes
  • monthly - Get Monthly Votes

Our Projects

  • DPost (This Is A Work In Progress, Beta Out Now!)