1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 07:41:56 +00:00
musix-oss/node_modules/dblapi.js
2019-10-10 16:43:04 +03:00
..
src Updated 2019-10-10 16:43:04 +03:00
typings Updated 2019-10-10 16:43:04 +03:00
.eslintrc.json Updated 2019-10-10 16:43:04 +03:00
index.js Updated 2019-10-10 16:43:04 +03:00
LICENSE Updated 2019-10-10 16:43:04 +03:00
package.json Updated 2019-10-10 16:43:04 +03:00
README.md Updated 2019-10-10 16:43:04 +03:00

dblapi.js

An official module for interacting with the discordbots.org API

Installation

npm install dblapi.js

Documentation

Documentation can be found here

Example

Example of posting server count with supported libraries (Discord.js and Eris)

const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token', client);

// Optional events
dbl.on('posted', () => {
  console.log('Server count posted!');
})

dbl.on('error', e => {
 console.log(`Oops! ${e}`);
})

Example of using webhooks to receive vote updates

const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});