Node.js Wrapper

You can use the official Node module to access the API from your Node.js code.

Advanced docs: https://discord-bots-group.github.io/npm-wrapper

You can see some examples below.

Step 1: Install the wrapper

npm i discord-bots-group/npm-wrapper

Step 2: Initialize the wrapper

const DBGWrapper = require('discordbots.group');
const dbg = new DBGWrapper('Bot ID', 'Token');

Get list stats

dbg.getStats().then(stats => {
console.log(stats);
}).catch((e) => {
console.error(e);
})

Get all bots on the site

dbg.getBots().then(bots => {
console.log(bots);
}).catch((e) => {
console.error(e);
})

Get all site users

dbg.getUsers().then(users => {
console.log(users);
}).catch((e) => {
console.error(e);
})

Get information for a specified bot

dbg.getBot('509277637928157195').then(bot => {
console.log(bot);
}).catch((e) => {
console.error(e);
})

Get information about the current bot

dbg.getCurrent().then(bot => {
console.log(bot);
}).catch((e) => {
console.error(e);
})

Post server count to DBG

dbg.updateCount(10).then(bot => {
console.log(bot);
}).catch((e) => {
console.error(e);
})

Check if a user has voted

dbg.hasVoted('449653897695461376').then(votes => {
console.log(votes);
}).catch((e) => {
console.error(e);
})

Gateway

const Client = require('discordbots.group');
const client = new Client.WebSocket({
tokens: ['Token 1', 'Token 2', 'Token 3'],
reconnect: true,
heartbeatInterval: 30
});
client.on('connected', () => console.log('Successfully connected to Gateway'));
client.on('disconnected', () => console.log('Disconnected from Gateway'));
client.on('reconnecting', () => console.log('Reconnecting to Gateway'));
client.on('error', (errors) => console.error('Errors', errors));
client.on('upvote', (data) => console.log(data));
client.on('pageView', (data) => console.log(data));
client.on('heartbeatAck', () => console.log('Heartbeat'));