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

dlist.js

v0.5.0

Published

An typescript API wrapper for the discordlist.gg api.

Downloads

7

Readme

ko-fi

About

This is an unofficial discordlist.gg package written for Typecript and JavaScript to interact with its public API. This lib can be used with any discord framework (or without any), for example with discord.js and eirs.

If you need help using this package, join the dlist.js Support Server. If you need help with the website or the raw API, join the dlist.gg Support Server and ask friendly there.

All examples are written for TypeScript, if you use JavaScript please use the commonJS import method.

Install

Download this npm package to use in your project with the following commands:

If you run node.js v18 or higher, use

# With npm
npm install dlist.js
# With yarn
yarn add dlist.js

For node.js v17 or lower, use

# With npm
npm install dlist.js node-fetch@2
# With yarn
yarn add dlist.js node-fetch@2

Getting API Token

To be able to interact with the api, you have to create a client, in the client's option you have to provide the discordlist.gg-token.

To get your token please visit https://discordlist.gg/bot/<BOT_ID>/dashboard/webhooks and look for the Token section.

Create Client

/* ES6 */
import { Client } from 'dlist.js';
// import { Client as dlistClient } from 'dlist.js';

/* commonJS */
const { Client } = require('dlist.js');
// const { Client: dlistClient } = require('dlist.js');

const client = new Client({
    token: 'xxx',
    bot: '857230367350063104',

    /* If using voting webhook (optional) */
    webhook: {
        port: 3000,
        authorization: 'abc',
        listenCallback: () => console.log('web server ready')
    }
});

Posting Guild data

Send your bot's server count stats to dlist.gg api so it can be displayed for your bot on the website! If you're using for example discord.js, replace 500 with client.guilds.cache.size. If you're using any other package, please read their docs or ask the package maintainers.

client.postGuilds(500);

Voting webhook

If you use this, you have to add the 'webhook' part in #Getting API Token to be able to recieve events.

Next, head over to https://discordlist.gg/bot/<BOT_ID>/dashboard/webhooks again and enter your server's IP and Port in the Webhook URl field, for example: http://123.456.78:3000.

In the Webhook Authorization field, create a strong key and treat it like a password, the same value has to be entered in the #Create Dlist Client.webhook.authorization in order to work!

client.on('vote', data => {
    console.log(data);
    /*
        {
            user_id: '857230367350063104',
            bot_id: '821472922140803112', 
            is_test: true
        }
    */
});