dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
665 stars 155 forks source link

Friendship Requests cannot be accepted #518

Closed Anubhav652 closed 1 year ago

Anubhav652 commented 1 year ago

Summary

Friendship requests cannot be accepted. It ends up erroring out.

Reproduction Steps

  1. Follow the code and setup a self-bot.
  2. Add the self-bot user as a friend. It will error out.

Code

class HCaptchaHandler(discord.CaptchaHandler):
    async def fetch_token(self, data: dict, proxy: str, proxy_auth: aiohttp.BasicAuth) -> str:
        print("CAPTCHA")
        solver = TwoCaptcha(config.get_config("API_KEY"))

        sitekey = data['captcha_sitekey']
        url = "https://discord.com/channels/@me"

        try:
            response = await asyncio.to_thread(
                solver.hcaptcha,
                sitekey=sitekey,
                url=url,
                data=data['captcha_rqdata']
            )
        except:
            raise

        print("Captcha solved")

        return response['code']

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_relationship_add(self, relation : Relationship):
        print(str(relation.type))
        match relation.type:
            case RelationshipType.incoming_request:
                await relation.accept()

client = MyClient(captcha_handler=HCaptchaHandler())
client.run(config.get_config("token"))

Expected Results

It's supposed to accept the friend request.

Actual Results

I get this error:

Traceback (most recent call last): File "\discord\client.py", line 507, in _run_event await coro(*args, **kwargs) File "discord-bot\bot.py", line 62, in on_relationship_add await relation.accept() File "discord-bot\venv\lib\site-packages\discord\relationship.py", line 298, in accept await self._state.http.add_relationship(self.user.id, action=RelationshipAction.accept_request) File "discord-bot\venv\lib\site-packages\discord\http.py", line 838, in request raise HTTPException(response, data) discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In miscallenous: Expected "Content-Type" header to be one of {'application/json'}.

System Information

Checklist

Additional Information

I went through https://github.com/dolfies/discord.py-self/issues/414, but I am using a captcha solver. But the captcha solver is not being triggered - there are no prints being triggered from the captcha handler.

I'm using @JamesTesting888's HCaptcha handler since it seems to be working for him from https://github.com/dolfies/discord.py-self/issues/485, so I don't think the issue is in the handler itself?

andrewthederp commented 1 year ago

I get this error too, I found out that sending a friend request will accept the friend request

dolfies commented 1 year ago

Missed this issue, should be fixed in the latest master commit!