add headers

This commit is contained in:
Victor Kotlin 2021-09-10 15:54:11 +03:00
parent 0b0182fe7f
commit aca61cbdc7
3 changed files with 17 additions and 7 deletions

View file

@ -41,7 +41,8 @@ class Bots:
botID : :class:`int`
Discord Bot's ID
"""
headers = {}
headers = {"Authorization": self.token}
async with self.session.get(f'{Config.general_api}/bot/{botID}', headers=headers) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)
@ -58,7 +59,8 @@ class Bots:
botID : :class:`int`
Discord Bot's ID
"""
headers = {}
headers = {"Authorization": self.token}
async with self.session.get(f'{Config.general_api}/bot/{botID}/comments', headers=headers) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)
@ -77,7 +79,9 @@ class Bots:
"""
if not self.token:
return "Require Authentication"
headers = {"Authorization": self.token}
async with self.session.post(f'{Config.general_api}/stats', headers=headers, json=stats) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)

View file

@ -42,7 +42,8 @@ class Servers:
serverID : :class:`int`
Discord Server's ID
"""
headers = {}
headers = {"Authorization": self.token}
async with self.session.get(f'{Config.general_api}/server/{serverID}', headers=headers) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)
@ -59,7 +60,8 @@ class Servers:
serverID : :class:`int`
Discord Server's ID
"""
headers = {}
headers = {"Authorization": self.token}
async with self.session.get(f'{Config.general_api}/server/{serverID}/comments', headers=headers) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)
@ -100,6 +102,7 @@ class Servers:
stats = custom_stats
headers = {"Authorization": self.token}
async with self.session.post(f'{Config.general_api}/server', headers=headers, json=stats) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)

View file

@ -35,7 +35,8 @@ class Users:
userID : :class:`int`
Discord User's ID
"""
headers = {}
headers = {"Authorization": self.token}
async with self.session.get(f'{Config.general_api}/profile/{userID}', headers=headers) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)
@ -52,7 +53,8 @@ class Users:
userID : :class:`int`
Discord User's ID
"""
headers = {}
headers = {"Authorization": self.token}
async with self.session.get(f'{Config.general_api}/profile/{userID}/comments', headers=headers) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)
@ -69,7 +71,8 @@ class Users:
userID : :class:`int`
Discord User's ID
"""
headers = {}
headers = {"Authorization": self.token}
async with self.session.get(f'{Config.general_api}/bots/{userID}', headers=headers) as resp:
data = await _json_or_text(resp)
status = Config.http_exceptions.get(resp.status)