Open
Description
Hey man! Could you guide me with this? What am I doing wrong?
async def send_message(self, message, api_key: str):
headers = self.__get_headers()
async with self.__session.post(
f"{self.BASE_URL}{self.TYPE_ENDPOINT_START}{self.channel_id}{self.TYPE_ENDPOINT_END}", headers=headers,
) as response:
if response.status == 204:
pass
else:
raise ValueError(f"Failed to type: {response.status} {await response.json()}")
async with self.__session.post(
f"{self.BASE_URL}{self.SEND_ENDPOINT_START}{self.channel_id}{self.SEND_ENDPOINT_END}", headers=headers,
json={"content": message, "flags": 0, "nonce": "f4yh5", "tts": False}
) as response:
if response.status == 200:
data = await response.json()
self.__message_id = data["id"]
return data["id"]
else:
data = await response.json()
solver = TwoCaptcha(apiKey=api_key)
result = await solver.hcaptcha(
sitekey="a9b5fb07-92ff-493f-86fe-352a2803b3df",
url='https://discord.com/',
data=data['captcha_rqdata'],
invisible=True,
UserAgent='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
'discord/1.0.9016 Chrome/108.0.5359.215 Electron/22.3.12 Safari/537.36'
)
headers.update({"X-Captcha-Key": result["code"]})
async with self.__session.post(
f"{self.BASE_URL}{self.SEND_ENDPOINT_START}{self.channel_id}{self.SEND_ENDPOINT_END}",
headers=headers,
json={"content": message, "flags": 0, "nonce": "nonce", "tts": False}
) as resp:
if resp.status == 200:
data = await resp.json()
self.__message_id = data["id"]
return data["id"]
else:
raise ValueError(f"Failed to send message: {resp.status} {await resp.json()}")
Metadata
Metadata
Assignees
Labels
No labels