dolfies / discord.py-self

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

CaptchaHandler not working #298

Closed scissoreth closed 2 years ago

scissoreth commented 2 years ago

Summary

CaptchaHandler not working

Reproduction Steps

this happened when i was trying to get a captcha token.

Code

import asyncio

import discord
from discord import Client

class MyClient(Client):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    async def on_ready(self):
        print(f'Запущен аккаунт {self.user}.')

        await self.accept_invite("mcsol")

class CaptchaSolver(discord.CaptchaHandler):
    async def fetch_token(data: dict, **kwargs) -> str:
        print(data)

        return 'token'

async def start_client():
    token = ""

    client = MyClient(captcha_handler=CaptchaSolver(), token=token)
    await client.login(token)
    await client.connect()

loop = asyncio.get_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(start_client())

Expected Results

Get captcha token

Actual Results

Traceback (most recent call last):
  File "D:\Apps\Anaconda\envs\test_captcha\lib\site-packages\discord\http.py", line 579, in request
    raise CaptchaRequired(response, data)  # type: ignore # Should not be text at this point
discord.errors.CaptchaRequired: 400 Bad Request (error code: -1): Captcha required

  File "D:\Apps\Anaconda\envs\test_captcha\lib\site-packages\discord\client.py", line 1872, in accept_invite
    data = await state.http.accept_invite(invite.code, type, **kwargs)
  File "D:\Apps\Anaconda\envs\test_captcha\lib\site-packages\discord\http.py", line 599, in request
    previous['captcha_key'] = await captcha_handler.fetch_token(e.json, self.proxy, self.proxy_auth)
TypeError: fetch_token() takes 1 positional argument but 4 were given

System Information

Checklist

Additional Information

No response

dolfies commented 2 years ago

Your function signature is incorrect.