turkishbotlistsapi
Version:
https://www.turkishbotlists.cf Adlı sitenin apisi
60 lines (52 loc) • 2.17 kB
JavaScript
let fetch = require("node-fetch")
class TBL {
constructor(token, client) {
this.token = token;
this.client = client;
this.postStats = this.constructor.postStats;
};
static async postStats(serverCount, shardCount){
if(!this.token) throw new Error("[TBL Token Bildiri]: Token Girmeyi Unutunuz!");
if(!this.client) throw new Error("[TBL ID Bildiri]: Botun ID'sini Belirtmeyi Unutunuz!");
if(!serverCount) throw new Error("[TBL Bildiri]: Sunucu Sayısını Belirtmeyi Unutunuz.");
if(isNaN(serverCount)) throw new Error("[TBL Bildiri]: Sunucu Değeri Yazı İle Yazılmaz!");
var requestOptions = {
method: 'POST',
headers: {
"authorization": this.token ,
"Content-Type":"application/json"
},
body: JSON.stringify({"serverCount": serverCount, "shardCount": shardCount || false})
};
fetch("https://turkishbotlistsi.glitch.me/api/stats/"+ this.client, requestOptions)
.then(response => response.text())
.then(console.log)
.catch(console.error);
}
async controlVote(memberID){
if(!this.token) throw new Error("[TBL Token Bildiri]: Token Girmeyi Unutun Sanırsam!");
if(!this.client) throw new Error("[TBL ID Bildiri]: Botun ID'sini Belirtmeyi Unutunuz!");
if(!memberID) throw new Error("[TBL ID Bildiri]: Kullanıcı ID'sini Belirtmeyi Unutunuz!");
try{
const UserStatus = await fetch('https://turkishbotlistsi.glitch.me/api/vote/'+this.client+'/user/'+memberID)
.then(res => res.text())
.then(body => JSON.parse(body).voteStatus)
return UserStatus;
} catch (err){
console.log(err)
}
}
async voteSize(){
if(!this.token) throw new Error("[TBL Token Bildiri]: Token Girmeyi Unutun Sanırsam!");
if(!this.client) throw new Error("[TBL ID Bildiri]: Botun ID'sini Belirtmeyi Unutunuz!");
try{
const VoteStatus = await fetch('https://turkishbotlistsi.glitch.me/api/vote/'+this.client)
.then(res => res.text())
.then(body => JSON.parse(body).vote)
return VoteStatus;
} catch (err){
console.log(err)
}
}
}
module.exports = TBL