blob: bca80e6598d0b6e9d6867fb0d21614dbcc3afd16 (
plain) (
blame)
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
|
import requests
import time
def session(token):
s = requests.Session()
s.headers.update({'Authorization': f'Bot {token}'})
return s
def post(s, endpoint, object):
while True:
response = s.post(f'https://discord.com/api/v10{endpoint}', json=object)
if response.status_code == 200:
return response.json()
if response.status_code == 429:
time.sleep(float(response.json()['retry_after']))
else:
print(response.status_code)
print(response.text)
exit(2)
def get(s, endpoint):
while True:
response = s.get(f'https://discord.com/api/v10{endpoint}')
if response.status_code == 200:
return response.json()
if response.status_code == 429:
time.sleep(float(response.json()['retry_after']))
else:
print(response.status_code)
print(response.text)
exit(2)
|