new-dblapi
Advanced tools
Comparing version 1.1.5 to 1.2.0
@@ -162,6 +162,37 @@ const http = require('http') | ||
} | ||
return await this.request(opts) | ||
return await JSON.parse(this.request(opts)) | ||
} | ||
/** | ||
* Get bots from discordbots.org | ||
* @param {Object} [query] A search query. | ||
* @param {number} [limit] A search limit. | ||
* @param {number} [offset] A set offset to skip. | ||
* @param {string} [search] A search string in the format of `field: value field2: value2` | ||
* @param {string} [sort] A field to sort by, add `-` at the beginning to reverse | ||
* @param {string} [fields] The fields to search, comma separated. | ||
* @returns {Promise<Object>} | ||
*/ | ||
async getBots(query = {}){ | ||
let { | ||
limit, | ||
offset, | ||
search, | ||
sort, | ||
fields | ||
} = query | ||
let path = `/api/bots?${limit ? `limit=${limit}&` : ''}${offset ? `offset=${offset}&` : ''}${search ? `search=${search}&` : ''}${sort ? `sort=${sort}&` : ''}${fields ? `fields=${fields}&` : ''}`.slice(0, -1) | ||
let opts = { | ||
'hostname': 'discordbots.org', | ||
'port': 443, | ||
'path': path, | ||
'method': 'GET', | ||
'headers': { | ||
'Authorization': this.token, | ||
} | ||
} | ||
return await JSON.parse(this.request(opts)) | ||
} | ||
/** | ||
* Check if a user has voted. | ||
@@ -168,0 +199,0 @@ * @param {string} id A user id. |
{ | ||
"name": "new-dblapi", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "A new dbl api.", | ||
@@ -18,2 +18,2 @@ "main": "dblapi.js", | ||
"license": "MIT" | ||
} | ||
} |
@@ -75,3 +75,3 @@ # Simple, Easy, discordbots.org API wrapper. Thing | ||
But, what are the cool methods? There are 7 whole methods, wow! So what do we got to work with? `getUser(id)`, `getBot([id[, votes]])` (votes is false by default, add true to get last 1000 votes), `checkVote(id)`, `getStats([id])`, `getWidget([id[, options])`, `postStats()`, `request(opts)` | ||
But, what are the cool methods? There are 8 whole methods, wow! So what do we got to work with? `getUser(id)`, `getBot([id[, votes]])` (votes is false by default, add true to get last 1000 votes), `getBots([query])`, `checkVote(id)`, `getStats([id])`, `getWidget([id[, options])`, `postStats()`, `request(opts)` | ||
@@ -84,2 +84,4 @@ What does all this do? I have no idea to be honest I made this with 10 minutes of free time and tested it once #gooddev. | ||
`getBots([query])` gets multiple bots. Query options are limit, offset, search, sort and fields. | ||
`checkVote(id)` will... check... a... users vote! It returns 1, or 0. 1 being yes, 0 being no (true/false, if you're feeling like that **This is a joke, it actually returns true/false don't get mad, but in JavaScript 1 = true and 0 = false anyways.**). | ||
@@ -103,2 +105,2 @@ | ||
Is it better than the official library? Never tested it against it, I did skip over some things, however. | ||
Is it better than the official library? Never tested it against it, I did skip over some things, however. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21302
5
384
103