dblwrapper.js

1.0.5 • Public • Published

dblwrapper.js


wrapper for doing anything with all major botlists


npm install dblwrapper.js
yarn add dblwrapper.js
pnpm add dblwrapper.js

Version Total Downloads

Table of Contents

About

Discord Bot List is a comprehensive library that simplifies interacting with major bot lists. It not only allows you to easily post your bot's statistics to multiple Discord bot lists but also provides various other useful functions. With this library, you can check who has voted for your bot, retrieve detailed information about bots and users, and much more. It supports popular bot listing platforms and is designed to be user-friendly.

Please note that while this library aims to support all major bot lists, some lists may not have been thoroughly tested yet.

Supported Bot Lists

Icon Name Website Class Name
Top.gg top.gg TopGG
More will be added soon

Examples

Posting Bot Stats

const { BotList, BotListPoster } = require('dblwrapper.js');

const lists = [
    new BotList.TopGG('you-bot-id', 'your-top.gg-api-token')
];

const poster = new BotListPoster(lists, {
    shardCount: () =>  1,
    guildCount: () => 25,
    userCount: () => 45778,
    voiceConnectionCount: () => 3,
});
// It is adviable to use real values for the above functions

poster.postStatistics(); //Post stats once
poster.startAutoPosting(); //Post stats every 30 minutes
poster.startAutoPosting(5 * 60 * 1000); //Post stats every 5 minutes
poster.stopAutoPoster(); //Stop auto posting

Recieving Webhooks

  • This is a beta feature and is not fully tested yet
  • Webhook URL: https://example.com/receive/<list>/vote
const { BotList, Webhook } = require('dblwrapper.js');

const lists = [
    new BotList.TopGG('you-bot-id', 'your-top.gg-api-token', 'webhook-token') //Webhook URL: https://example.com/receive/topgg/vote
];

const poster = new Webhook(lists, {
port: 3000, // Port to listen on
handleAfterVote: (req, res) => {
    // Do something after a user votes
}, // This isnt required 

});
// If you don't give handleAfterVote function, it will send a 200 response to the webhook and inbuilt events will be emitted
webhook.on(Webhook.Events.Ready, () => {
    // This event is emitted when the webhook is ready
    console.log("Webhook is ready!")
})
webhook.on(Webhook.Events.NewVote, (botList, vote) => {
    // This event is emitted when a new vote is recieved
    console.log(`New vote on ${botList.key} from ${vote.userId}`)
})

Bot List Specific Functions

Top.gg

  • Importing
      const { BotList : TopGG } = require('dblwrapper.js');
  • Constructor
        const topgg = new TopGG('bot-id', 'api-token', 'webhook-password');
  • Methods
      // Get bot information from Top.gg
      topgg.getBot('bot-id').then(response => {
          console.log(response);
      }).catch(console.error);
      // Get user information from Top.gg
      topgg.getUser('user-id').then(response => {
          console.log(response);
      }).catch(console.error);
      // Check if user has voted for your bot
      topgg.hasVoted().then(response => {
          console.log(response);
      }).catch(console.error);
      /*
      true -> user voted in the last 24 hours
      false -> user didnt vote in the last 24 hours
      */

Package Sidebar

Install

npm i dblwrapper.js

Weekly Downloads

2

Version

1.0.5

License

Apache-2.0

Unpacked Size

26.8 kB

Total Files

10

Last publish

Collaborators

  • visa2code