bfd-api-redux
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "bfd-api-redux", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A node.js wrapper for the Bots For Discord API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -37,3 +37,3 @@ ## NOTICE & INFO | ||
```js | ||
api.getUser("254287885585350666").then(user => { | ||
api.getUser("254287885585350666").then(user => { //Provide a user id | ||
console.log(user) | ||
@@ -45,3 +45,3 @@ }) | ||
```js | ||
api.getUserBots("254287885585350666").then(bots => { | ||
api.getUserBots("254287885585350666").then(bots => { //Provide a user id | ||
console.log(bots) | ||
@@ -53,3 +53,3 @@ }) | ||
```js | ||
api.getUser("621352902656524288").then(bot => { | ||
api.getUser("621352902656524288").then(bot => { //Provide a bot id | ||
console.log(bot) | ||
@@ -61,3 +61,3 @@ }) | ||
```js | ||
api.getWidget("621352902656524288").then(widget => { | ||
api.getWidget("621352902656524288").then(widget => { //Provide a bot id | ||
console.log(widget) | ||
@@ -67,2 +67,16 @@ }) | ||
### Cheking a vote for one specific user (including structure) | ||
```js | ||
api.checkVote("254287885585350666").then(vote => { //Provide a user id | ||
console.log(vote) //true or false + vote structure | ||
}) | ||
``` | ||
### Cheking a vote for one specific user (lightweight structure) | ||
```js | ||
api.checkVoteLight("254287885585350666").then(vote => { //Provide a user id | ||
console.log(vote) //true or false | ||
}) | ||
``` | ||
@@ -73,2 +73,30 @@ const EventEmitter = require("events"); | ||
async checkVoteLight(userid) { | ||
return new Promise(async (resolve, reject) => { | ||
const votes = await this.getVotes12(); | ||
if (Array.isArray(votes.entries)) { | ||
resolve(votes.entries.some(vote => vote.userid === userid)) | ||
} else { | ||
resolve(false); | ||
} | ||
}) | ||
} | ||
async checkVote(userid) { | ||
return new Promise(async (resolve, reject) => { | ||
const votes = await this.getVotes12(); | ||
if (Array.isArray(votes.entries)) { | ||
let structure = { voted: true, votes: []}; | ||
votes.entries.forEach(vote => { | ||
if (vote.userid === userid) { | ||
structure.votes.push(vote) | ||
} | ||
}) | ||
resolve(structure) | ||
} else { | ||
resolve(false); | ||
} | ||
}) | ||
} | ||
async getWidget(id) { | ||
@@ -75,0 +103,0 @@ return new Promise((resolve, reject) => { |
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
7750
158
78