-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbotlists.py
More file actions
42 lines (37 loc) · 1.58 KB
/
botlists.py
File metadata and controls
42 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import aiohttp
import json
TOPGGBASE = "https://top.gg/api/bots/789202881336311849"
BOTSGGBASE = "https://discord.bots.gg/api/v1/bots/789202881336311849"
DBLBASE = "https://discordbotlist.com/api/v1/bots/789202881336311849"
DBOATSBASE = "https://discord.boats/api/bot/789202881336311849"
class BotLists:
def __init__(self, db):
f = open("./secret/botlisttokens.json",'r')
self.tokens = json.load(f)
f.close()
self.db = db
self.session = aiohttp.ClientSession()
async def isVoted(self, uid):
if self.db.checkVotedUser(uid):
return True
else:
resp = await self.session.get(TOPGGBASE+f"/check?userId={uid}", headers={"Authorization": self.tokens["topgg"]})
resp = json.loads(await resp.text())
if resp["voted"] > 0:
self.db.addVotedUser(uid)
return True
else:
return False
async def postServerCount(self, svcount):
await self.session.post(TOPGGBASE+"/stats",
headers={"Authorization":self.tokens["topgg"]},
data={"server_count":svcount})
await self.session.post(BOTSGGBASE+"/stats",
headers={"Authorization":self.tokens["botsgg"]},
data={"guildCount":svcount})
await self.session.post(DBLBASE+"/stats",
headers={"Authorization":self.tokens["discordbotlist"]},
data={"guilds":svcount})
await self.session.post(DBOATSBASE,
headers={"Authorization":self.tokens["discordboats"]},
data={"server_count":svcount})