Skip to content

CaptchaHandler or Bot.handle_captcha() ? #652

Answered by dolfies
TheRealRedSlime asked this question in Help
Discussion options

You must be logged in to vote

Captcha handling was rewritten in v2.1 because it was unnecessarily complicated.

The Optional[Callable[[CaptchaRequired, Client], Awaitable[str]])] syntax essentially means it accepts a method that looks like this:

async def captcha(exc: discord.CaptchaRequired, bot: commands.Bot) -> str:
    # do stuff here, e.g. run your existing two_captcha() function in an executor
    log.debug(f'Got a CAPTCHA with sitekey {exc.sitekey}')

bot = commands.Bot(captcha_handler=captcha)

This is handled by the Bot.handle_captcha() method you mentioned, which can alternatively be overrided if you are already subclassing Client/Bot:

class MyBot(commands.Bot):
    async def handle_captcha(self, exc: discord.C…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@TheRealRedSlime
Comment options

Answer selected by dolfies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants