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

blist.javascript

v1.5.4

Published

JavaScript wrapper for the blist.xyz API

Downloads

7

Readme

blist.js

Getting Started

This is the documentation for the JavaScript wrapper for the Blist API. This documentation includes all information about installing and using the wrapper. This API requires your bot to be using discord.js and a Discord.Client() instance.

Installing

To install the API wrapper, follow these simple steps:

  1. Open a command prompt in your bot's directory, or create a new directory and run npm init.
  2. Run npm i blist.javascript. This will install the dependency and add it to your dependency list.
  3. blist.js should now be successfully installed.

Creating a new instance

To create a new instance for the wrapper, we must first import the module. Once we imported the module, we can create a new instance. See the code example below. An API key is optional, but is required for multiple functions.

// Import the blist.js package
const blist = require("blist.javascript");

// Create a new blist instance
const client = new blist(bot, apiKey);

Listen for votes using a webhook

If you want to handle your bot votes, you can do so by creating a webhook.

// Create a new blist instance
const client = new blist(bot, apiKey);
const bot = new discordjs.Client();

bot.on("ready" => {
  // Start a new webhook on port 4000, default port is 8000
  client.startWebhook(4000);
  // Optional 
  // client.startWebhook(PORT, {emit: "NAME", endpoint: "NAME"})
  // bot.on("emit_name")
  // http://URL:PORT/ENDPOINT_NAME
  
  // Stop your webhook
  client.stopWebhook();
});

// Detects when someone votes for your bot
bot.on("botVote", (vote) => console.log(vote));

// Login your bot
bot.login(token);

Fetch user and bot stats

To fetch information and statistics about a user or a bot, you can use the following functions.

// Fetch bot stats
client.fetchBot(id).then((bot) => console.log(bot));

// Fetch user stats
client.fetchUser(id).then((user) => console.log(user));

Fetch bot votes

To fetch the votes for your bot, this requires initializing a bot instance with an API key.

// Fetch bot votes, id is not required if discord.js bot client is provided on client creation
client.fetchVotes().then((votes) => console.log(votes));

Fetch bot reviews

Fetch the Discord.Client()'s bot reviews!

// Returns: {reviews: [Review_Objects]}
client.fetchReviews().then((reviews) => console.log(reviews));

Check user(s) votes

To check if certain user(s) have voted, use this method!

// 1 user
client.hasVoted("USER_ID").then(v => console.log(v))
// Returns boolean

// multiple users
client.hasVoted(["USER_ID", "USER_ID", "USER_ID", "..ETC"]).then(ids => console.log(ids));
// Returns an array of user ids that have voted.

Post bot stats

Posting bot stats requires you to provide an API key on client creation.

// Post bot stats, default
client.postStats().then(() => console.log("Posted stats succesfully!"));

// Provide the server_count and shards_count yourself. 
client.postStats(server_count, shards_count).then(() => console.log(`Posted stats successfully!`));

Autoposting bot stats

Automatically post bot stats. Requires you to provide an API key on client creation.

// Start autoposting; the interval is in minutes
client.startAutopost(30).then(() => console.log("Now posting stats"));

client.stopAutopost().then(() => console.log("Stopped autoposting stats"));