Skip to content

Instantly share code, notes, and snippets.

@Fyko
Last active April 23, 2019 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fyko/ef0e799edd548360217d465d3ad8de18 to your computer and use it in GitHub Desktop.
Save Fyko/ef0e799edd548360217d465d3ad8de18 to your computer and use it in GitHub Desktop.
An example on using the new-dblapi Node package to post stats & handle votes

This is a quick guide on using the new-dblapi npm package to post your bot stats to discordbots.org. This package is only compatible with discord.js.

Here are the the sources that are mentioned in the comments below. link 1 link 2 link 3

const { Client } = require('discord.js');
const dbl = require('new-dblapi'); // (link 1)
const client = new Client();

client.on('ready', () => {
    console.log(`Bot Ready! Logged in as ${client.user.tag}`);

    // initialize DBL class
    const DBL = new dbl('insert dbl token', {
        port: 5000, // port for WH to listen on (link 2)
        path: 'vote', //what follows the wh link (link 2)
        auth: 'webhok authorization', // authorization for WH (link 2)
        delay: 900000, // delay for posting stats AUTOMATICALLY (link 3) - defaults to 15m
    }, client); // you must pass through client

    DBL.on('vote', (vote) => {
        console.log(`New Vote! ${vote.user}`) // vote.user returns a user id
    })

});

client.login('bot token');

See a mistake in my example? Come yell at me here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment