1.0.4 • Published 6 years ago
dblstats.js v1.0.4
Select Array
The promise always returns the raw already parsed JSON. To get the results you want to do something like .then(bots => bots.results)
. To get the time this info was updated do .then(bots => bots.updated)
The array at the end of these functions will determine what info is returned. (Bot ID is always returned).
Select Type | Type | Description |
---|---|---|
defAvatar | string | the Default avatar for this bot. |
invite | string | The bots invite url. |
github | sring | The Github page for this bot. |
website | string | The website associated with this bot. |
longdesc | string | The text or HTML used in the long description. |
shortdesc | string | The text in the short Description. |
prefix | string | The prefix set on DBL. |
lib | string | The library used to make this bot. |
clientid | string | The application ID for this bot. |
avatar | string | The bots current avatar. |
discriminator | number | The discriminator for the bot. |
username | string | The bots username. |
date | ISO 8601 | Date the bot was added to DBL. |
serverCount | number | The amount of servers the bot is in. (-1 if not posted) |
shardCount | number | The amount of shards started with this Bot. (-1 if none) |
shards | array | An array containing the amount of servers per shard. (empty if no Shards) |
points | number | The amount of upvotes on DBL. |
certified | boolean | Whenever this bot is certified or not. |
owners | array | An array of all owner IDs. |
The array looks like ["avatar", "username", "discriminator", "shards", "serverCount"]
, which would return the Avatar, Username, Discrim, Servers/shard and total Server count in the results array.
Get a bot via ID
const dbl = require("dblstats.js")
dbl.getBot("323128638444929025", ["avatar", "username", "serverCount"]).then(bots => {
let res = bots.results.map(bot =>
`The bot ${bot.username} has the avatarHash ${bot.avatar} and ${bot.serverCount} servers`
)
let lastupdated = new Date(bots.updated)
console.log(res.join("\n")+"\nLast Updated:" + lastupdated)
});
Get bots matching criterias
const dbl = require("dblstats.js")
dbl.getBots({username: "Shuvi", discrim: "3521"}, ["avatar", "username", "serverCount"]).then(bots => {
let res = bots.results.map(bot =>
`The bot ${bot.username} has the avatarHash ${bot.avatar} and ${bot.serverCount} servers`
)
console.log(res.join("\n"))
});
dbl.getBots({prefix: "!", offset: 20, limit:20}, ["avatar", "username", "serverCount"]).then(bots => {
let res = bots.results.map(bot =>
`The bot ${bot.username} has the avatarHash ${bot.avatar} and ${bot.serverCount} servers`
)
console.log(res.join("\n"))
});
The object can contain anything you can see listed in the Select Array table above.
Filtering values
Prefix, Short/Long Description includes
const dbl = require("dblstats.js")
dbl.filterBots({type: "shortdesc", filter: "includes", toFilter: "unique", limit: 5}, ["username", "serverCount"])
.then(bots => {
let res = bots.results.map(bot =>
`The bot ${bot.username} has ${bot.serverCount} servers`
)
console.log(res.join("\n"))
});
dbl.filterBots({type: "prefix", filter: "includes", toFilter: "s!", limit: 2}, ["username", "serverCount"])
.then(bots => {
let res = bots.results.map(bot =>
`The bot ${bot.username} has ${bot.serverCount} servers`
)
console.log(res.join("\n"))
});
serverCount, shardCount or points are above/below X
const dbl = require("dblstats.js")
dbl.filterBots({type: "serverCount", filter: ">=", toFilter: 700, limit: 3}, ["username", "serverCount"])
.then(bots => {
let res = bots.results.map(bot => `The bot ${bot.username} has ${bot.serverCount} servers`)
console.log(res.join("\n"))
});
dbl.filterBots({type: "shardCount", filter: "<=", toFilter: 20}, ["username", "serverCount", "shardCount"])
.then(bots => {
let res = bots.results.map(bot =>
`The bot ${bot.username} has ${bot.serverCount} servers with ${bot.shardCount} shards`
)
console.log(res.join("\n"))
});
//points are upvotes
dbl.filterBots({type: "points", filter: ">", toFilter: 100, offset: 5}, ["username", "serverCount", "points"])
.then(bots => {
let res = bots.results.map(bot =>
`The bot ${bot.username} has ${bot.serverCount} servers with ${bot.points} upvotes`
)
console.log(res.join("\n"))
});