feat: custom solve captcha function

This commit is contained in:
March 7th
2023-01-03 13:56:24 +07:00
parent 84e2e23468
commit c9d2d1bd18
7 changed files with 30 additions and 5 deletions

View File

@@ -16,6 +16,9 @@ class BaseClient extends EventEmitter {
if (options.intents) {
process.emitWarning('Intents is not available.', 'DeprecationWarning');
}
if (typeof options.captchaSolver === 'function') {
options.captchaService = 'custom';
}
/**
* The options the client was instantiated with
* @type {ClientOptions}

View File

@@ -984,7 +984,7 @@ class Client extends BaseClient {
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaService', captchaServices.join(', '));
}
// Parse captcha key
if (options && captchaServices.includes(options.captchaService)) {
if (options && captchaServices.includes(options.captchaService) && options.captchaService !== 'custom') {
if (typeof options.captchaKey !== 'string') {
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a string');
}
@@ -996,6 +996,9 @@ class Client extends BaseClient {
break;
}
}
if (options && typeof options.captchaSolver !== 'function') {
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaSolver', 'a function');
}
if (options && typeof options.DMSync !== 'boolean') {
throw new TypeError('CLIENT_INVALID_OPTION', 'DMSync', 'a boolean');
}