$ npm i sbl-npm.js
const main = require('sbl-npm.js');
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client); // It will be djs by defualt
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client, 1380000); // with custom autopost time (MilliSeconds) Should be Atleast more than 23 Minutes
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client, 1380000, "eris"); // with package name which you are using (Current Options: eris and djs) with eris
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client, "djs"); // with djs
// By Defualt it will be djs (djs = discord.js and eris = eris)
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client, 1380000, "djs"); // with all custom options
In Eris Package You have to Give Time of AutoPost before giving name of eris and in discord.js you dont even have to name djs
apibl.post().then(console.log); //post servers count and users count both
apibl.on('posted', data => {
console.log(data);
});
apibl.bot('id of the bot').then(res => console.log(res.username + '\n' + res)); //bot who is in SBL information
apibl.votes().then(console.log); //all votes who your bot have
apibl.isVoted('id of user').then(console.log); //if the user is voted for your bot | returning: true/false (boolean)
const webhook = new main.Webhook('YOUR TOKEN GIVEN FROM BOTLIST');
webhook.login('/Vote', '3000'); //you can edit the port (only numbers)
webhook.on('vote', vote => {
console.log(`User id: ${vote.user}\nAll data: ${vote}`);
});
/**
* returning
* {
bot: '767341532093087755',
user: '728512329888825396',
votes: '5',
test: null
}
*/
const express = require('express');
const app = express();
app.post('/Vote', webhook.advanced(), (req, res) => {
console.log(req.vote);
});
app.listen('3000', () => {
console.log('App listening on port 3000');
});
Full Discord.js Example
const discord = require('discord.js');
const main = require('sbl-npm.js');
const client = new discord.Client();
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client);
const webhook = new main.Webhook('YOUR TOKEN GIVEN FROM BOTLIST');
client.on('ready', () => {
console.log('Logged');
apibl.post();
});
apibl.on('posted', data => {
console.log(data);
});
webhook.login('/Vote', '3000'); //you can edit the port (only numbers)
webhook.on('vote', vote => {
console.log(`User id: ${vote.user}\nAll data: ${vote}`);
});
client.on('message', message => {
if (message.content.startsWith('!votes')) {
let votes = await apibl.votes(client.user.id);
message.channel.send(`I have ${votes} votes`);
}
});
client.login('DISCORD BOT TOKEN');
Full Eris Example
const Eris = require('eris');
const client = new Eris("DISCORD BOT TOKEN");
const main = require("sbl-npm.js");
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client, 1380000, "eris");
client.on("ready", () => {
console.log('Logged');
apibl.post();
});
apibl.on('posted', data => {
console.log(data);
});
webhook.login('/vote', '3000'); //you can edit the port (only numbers) NOTE: PUT .login METHOD BEFORE THE .on('vote') METHOD
webhook.on('vote', vote => {
console.log(`User id: ${vote.user}\nAll data: ${vote}`);
});
client.on("messageCreate", message => {
if (message.content.startsWith('!votes')) {
let votes = await apibl.votes(client.user.id);
client.createMessage(message.channel.id, `I have ${votes} votes`);
}
});
client.connect();