Skip to content

Commit 5d9ed07

Browse files
committed
Paradise Bots List
1 parent 61c8106 commit 5d9ed07

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/Client.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,55 @@ class WebhooksManager extends EventEmitter {
250250
});
251251
}
252252

253+
async PBLVoteHook(url, auth, toggle) {
254+
if (toggle == false) {
255+
return console.log(
256+
chalk.red("[BLWEBHOOKS] ParaiseBots vote hooks have been disabled.")
257+
);
258+
} else if (toggle == true) {
259+
console.log(
260+
chalk.green("[BLWEBHOOKS] ParaiseBots vote hooks have been enabled.")
261+
);
262+
}
263+
app.post(`/${url}`, async (req, res) => {
264+
// Respond to invalid requests
265+
res.setHeader("X-Powered-By", "BLWebhooks.js/Express");
266+
if (req.header("Authorization") != auth)
267+
console.log("Failed Access - ParaiseBots Endpoint");
268+
if (req.header("Authorization") != auth)
269+
return res.status(403).send(
270+
JSON.stringify({
271+
error: true,
272+
message:
273+
"[BLWEBHOOKS] You don't have access to use this endpoint. - ParaiseBots",
274+
})
275+
);
276+
277+
// Use the data on whatever you want
278+
console.log(req.body);
279+
// VotingModel.findOneAndUpdate({ userID : req.vote.user }, {$inc : {'totalVotes' : 1}});
280+
const userID = req.body.userID;
281+
const botID = req.body.bot;
282+
const userName = req.body.user;
283+
const type = req.body.type;
284+
const List = "ParaiseBots";
285+
this.client.emit("PBL-voted", userID, botID, userName, type);
286+
this.client.emit("vote", userID, botID, List);
287+
setTimeout(
288+
() => this.client.emit("voteExpired", userID, botID, List),
289+
1000 * 60 * 60 * 24
290+
);
291+
292+
// Respond to IBL API
293+
res.status(200).send(
294+
JSON.stringify({
295+
error: false,
296+
message: "[BLWEBHOOKS] Received the request!",
297+
})
298+
);
299+
});
300+
}
301+
253302
async VoidBotsVoteHook(url, auth, toggle) {
254303
if (toggle == false) {
255304
return console.log(

0 commit comments

Comments
 (0)