1.10.0 • Published 3 years ago

paradiseapi.js v1.10.0

Weekly downloads
18
License
MIT
Repository
github
Last release
3 years ago

Paradise Bot List API Wrapper

The official NPM Module for interacting with the Paradise API


Support


Installation

npm i paradiseapi.js@latest

or

npm i paradiseapi.js@1.10.0

or

npm i paradiseapi.js --save


Hard Coded Install

Append the Line below to your package.json

    "paradiseapi.js": "^1.10.0",

• Save and profit


Ratelimits

You can POST Server and Shard Count stats once every 5 minutes


Response

Error 429 : [PBL] (429): Your are being ratelimited, 1 request per 5 mins.

Error 404 : [PBL] (404): Can't find server_count.

Error 404 : [PBL] (404): Authorization header not found.

Error 400 : [PBL] (400): server_count not integer.

Error 404 : [PBL] (404): Bot not found!

Error 400 : [PBL] (400): Incorrect authorization token.

Error 404 : [PBL] (404): Go generate auth token for your bot!

Error 400 : [PBL] (400): shard_count not integer.

Success 200 : 200: Your Stats Has Been Posted.


Posting Stats

Constructor

PBL(client, token)
Arguments
ParameterTypeOptionalDescription
tokenStringNoThe API Auth Token found on your bots page.
clientSnowflakeNoThe Client ID for the bot you want to post stats to.

Discord.js v12 Example

const Discord = require("discord.js")
const client = new Discord.Client()
const prefix = "!";
const PBL = require("paradiseapi.js")
const pbl = new PBL(client.user.id,"bot-auth-token")

client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}.`)
setInterval(() => {
/* Here is where we Post the stats to the Site (Only use one of these) */
   pbl.post(client.guilds.cache.size) /* Will `POST` server count*/
   //pbl.post(client.shard.count) /* Will `POST` shard count*/
   //pbl.post(client.guilds.cache.size, client.shard.count) /* Will `POST` server and shard count*/
  })
}, 300000) //5 Minutes in MS

client.on("message", message => {
    if(message.author.bot) return
    if(message.content == prefix + "ping"){
        message.reply(`Pong! it took ${client.ws.ping}`)
    }
})

client.login("token")

Discord.js v12 Example (Wtih event handler

module.exports = class extends EventClass {
    constructor() {
        super('ready', {
            emitter: 'client',
            event: 'ready'
        });
    }

    exec() {
  const PBL = require("paradiseapi.js")
  const pbl = new PBL("BOT_ID_HERE","AUTH_TOKEN_HERE")
  
/* Here is where we Post the stats to the Site (Only use one of these) */
   pbl.post(client.guilds.cache.size) /* Will `POST` server count*/
   //pbl.post(client.shard.count) /* Will `POST` shard count*/
   //pbl.post(client.guilds.cache.size, client.shard.count) /* Will `POST` server and shard count*/
    }
}

(Discord Akairo) Example

const Discord = require('discord.js');
const { Listener } = require('discord-akairo');
const request = require('superagent');
const fetch = require("node-fetch")
const Client = new Discord.Client()


module.exports = class ReadyListener extends Listener {
    constructor() {
        super('ready', {
            emitter: 'client',
            event: 'ready'
        });
    }

    exec() {
  const PBL = require("paradiseapi.js")
  const pbl = new PBL("BOT_ID_HERE","AUTH_TOKEN_HERE")
  
/* Here is where we Post the stats to the Site (Only use one of these) */
   pbl.post(client.guilds.cache.size) /* Will `POST` server count*/
   //pbl.post(client.shard.count) /* Will `POST` shard count*/
   //pbl.post(client.guilds.cache.size, client.shard.count) /* Will `POST` server and shard count*/
    }
}

Getting Stats

Constructor

PBL()
Arguments
ParameterTypeOptionalDescription
usernameStringYesThe bots username.
botidSnowflakeYesThe bots ID.
ownerSnowflakeYesThe bot owners ID.
additionalOwnersStringYesThe IDs of all additional owners (if any).
PrefixStringYesThe bots listed prefix(s).
shortDescriptionStringYesThe bots short description (Shown on cards).
longDescriptionStringYesThe bots long description (Can be markdown).
votesNumberYesThe bots total number of upvotes.
usersVotedStringYesIDs of the last 10 users who voted (May return less).
usersVotedTotalNumberYesTotal number of Individual Users who have voted (Each user = 1).
serverStringYesLink to the bots support server.
websiteStringYesLink to the bots website.
githubStringYesLink to the bots github.
donateStringYesLink to donate to the bot.
tagsStringYesList of the bots tags.
libraryStringYesThe library the bot was made with.
serversNumberYesNumber of total servers the bot is in.
shardsNumberYesNumber of total shards the bot has.

Example

const Discord = require("discord.js")
const client = new Discord.Client()
const prefix = "!";
const PBL = require("paradisebotsapi.js")
const stats = new PBL()
 
client.on("ready", () => { // ready listenerconsole.log(`Logged in as ${client.user.tag}`)}) 
client.on("message", message => { // message listener
    if(message.author.bot) return;
    if(message.channel.type !== "text") return;
    if(!message.content.toLowerCase().startsWith(prefix)) return;
    if(message.content == (prefix + "ping")){
        message.reply(`Pong ${client.ws.ping}ms`)
    }
     if(message.content == (prefix + "stats")){
        stats.get(client.user.id, function(data){
        let embed = new MessageEmbed()
        .setTitle(data.username)
        .setDescription(`Vote here: https://paradisebots.net/api/v1/bots/${client.user.id}`)
        .addField("Total Votes", data.votes);

        message.channel.send(embed)
        })
    }
})
 
 
client.login("token")

Example (GET User)

const Discord = require("discord.js")
const client = new Discord.Client()
const prefix = "!";
const PBL = require("paradisebotsapi.js")
const user_stats = new PBL()
 
client.on("ready", () => { // ready listenerconsole.log(`Logged in as ${client.user.tag}`)}) 
client.on("message", message => { // message listener
    if(message.author.bot) return;
    if(message.channel.type !== "text") return;
    if(!message.content.toLowerCase().startsWith(prefix)) return;
    if(message.content == (prefix + "ping")){
        message.reply(`Pong ${client.ws.ping}ms`)
    }
     if(message.content == (prefix + "stats")){
        user_stats.getUser("SOME_USER_ID", function(data){ // USER ID Should be String
        let embed = new MessageEmbed()
        .setTitle(data.userName)
        .setDescription('The info here is fetched from the Paradise Bots API')
        .addField("User ID", data.userID, true)
        .addField("Bio", data.bio, true)
        .addField("Certified User?", data.certifiedUser, true)
        .addField("Vote Banned?", data.voteBanned, true)
        .setFooter(`Requested By: ${message.author.username}`)
 
        message.channel.send(embed)
        })
    }
})
 
 
client.login("token")

1.0.9

3 years ago

1.10.0

3 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.3-Patch

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago