captcha-discordv2
v1.1.9
Published
This module generates a CAPTCHA image code. It is designed to be simple to use while providing the flexibility to adjust the CAPTCHA length and ensuring that the text is appropriately sized and centered within the image.
Downloads
28
Maintainers
Readme
Captcha Generator
This module generates a CAPTCHA image code. It is designed to be simple to use while providing the flexibility to adjust the CAPTCHA length and ensuring that the text is appropriately sized and centered within the image.
Installation
To install this package, run the following command in your terminal:
npm install captcha-discord
Usage
const { captchaCreate } = require('captcha-discord');
// Generates a CAPTCHA with 10 characters
const captcha = captchaCreate(10);
member.send(captcha);
Parameters
length (optional): Specifies the number of characters in the CAPTCHA. Default is 5 characters if not specified. The function automatically adjusts the length to a minimum of 5 and a maximum of 30 characters.
Adaptive Font Size
The font size within the CAPTCHA is adaptively adjusted according to the number of characters to ensure the text remains clear and fits within the bounds of the image. This makes the CAPTCHA robust against varying text lengths.
Error Handling
const { captchaCreate } = require('captcha-discord');
// Attempting to generate a CAPTCHA with too many or too few characters
const captcha = captchaCreate(35); // This will adjust the length to 30 characters
const smallCaptcha = captchaCreate(3); // This will adjust the length to 5 characters