# sbl-npm.js

> Botlist API for Solo Bot List (SBL) bots.solonodes.xyz

Latest version **1.3.1** (published 2021-08-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install sbl-npm.js
pnpm add sbl-npm.js
yarn add sbl-npm.js
bun add sbl-npm.js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2021-08-27 |
| First published | 2021-08-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | dhvit |
| Maintainers | dhvit |
| Keywords | solobl, soloapi, solonpm, soloblspi, solobotlist, solobotlistapi |

## Links

- npm: https://www.npmjs.com/package/sbl-npm.js
- Homepage: https://github.com/SoloNodes/soloblapi#readme
- Issues: https://github.com/SoloNodes/soloblapi/issues
- npm.io page: https://npm.io/package/sbl-npm.js

## Dependencies (5)

- [events](https://npm.io/package/events.md) ^3.3.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [raw-body](https://npm.io/package/raw-body.md) ^2.4.1
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1
- [querystring](https://npm.io/package/querystring.md) ^0.2.1

## Recent versions

- 1.3.1 (latest) — 2021-08-27
- 1.3.0 — 2021-08-27
- 1.2.0 — 2021-08-26
- 1.1.0 — 2021-08-26
- 1.0.0 — 2021-08-26

## README

<div align="center">

  <p>
    <a href="https://www.npmjs.com/package/sbl-npm.js"><img src="https://nodei.co/npm/sbl-npm.js.png?downloads=true&stars=true" alt="NPM Banner"></a>
  </p>

  <p>
    <a href="https://www.npmjs.com/package/sbl-npm.js"><img src="https://img.shields.io/npm/v/sbl-npm.js?maxAge=3600" alt="NPM version" /></a>
    <a href="https://www.npmjs.com/package/sbl-npm.js"><img src="https://img.shields.io/npm/dt/sbl-npm.js?maxAge=3600" alt="NPM downloads" /></a>
  </p>
</div>

## Install
```sh
$ npm i sbl-npm.js
```

## Definite
```js
const main = require('sbl-npm.js');
```

## Examples

### Setup

##### Go to your bot page</p>
<img src="https://media.discordapp.net/attachments/872390238738210896/880337535732174858/unknown.png">

##### Click Copy and then paste in this client
<div style="margin: 20px;"></div>

```js
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client); // It will be djs by defualt
```
```js
const apibl = new main.Client('YOUR TOKEN GIVEN FROM BOTLIST', client, 1380000); // with custom autopost time (MilliSeconds) Should be Atleast more than 23 Minutes
```
```js
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
```
```js
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)
```
```js
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__**

<br>

### Post Stats
```js
apibl.post().then(console.log); //post servers count and users count both


apibl.on('posted', data => {
  console.log(data);
});
```

<br>
<hr>
<br>

### Informaion
```js
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)
```

## Vote

### Setup

##### Go to Edit section of your bot</p>
<img src="https://media.discordapp.net/attachments/872390238738210896/880335715416830002/unknown.png">

<h5>
  <li>On <strong>Webhook URL</strong> put your domain (example.com, example.glitch.me, example.user.repl.co) and path (/Vote) and the result is &#60;domain.com&#62;/Vote</li>

  <li>Your Bot Token will be in Your Bot Page Only<strong>Authorization</strong></li>
</h5>

```js
const webhook = new main.Webhook('YOUR TOKEN GIVEN FROM BOTLIST');
```

<br>

### Default Method
```js
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
 
 
}
 */

```
### Advanced Method
```js
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](https://npmjs.com/package/discord.js) Example
```js
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](https://npmjs.com/package/eris) Example
```js
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();
```

<hr>

### [soloblapi](https://www.npmjs.com/package/sbl-npm.js) is affiliated with **discord bot list ([SBL](https://bots.solonodes.xyz))**

<br>

---
_Source: https://npm.io/package/sbl-npm.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
