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)