amtixdev-captcha-verification
v1.0.0-beta
Published
A simple npm package for generating and verifying captcha codes with numbers for Discord bots.
Downloads
9
Maintainers
Readme
Captcha Verification for Discord Bots
A simple npm package for generating and verifying captcha codes with numbers for Discord bots.
Installation
npm install captcha-verification
Usage
const Discord = require('discord.js');
const CaptchaVerifier = require('captcha-verification');
const client = new Discord.Client();
const captchaVerifier = new CaptchaVerifier(client);
client.on('message', (message) => {
if (message.author.bot) return;
// Example: Send captcha to the same channel when a certain command is sent
if (message.content.toLowerCase() === '!sendcaptcha') {
captchaVerifier.sendCaptchaMessage(message.channel);
}
// Example: Verify the user's input
const userInput = message.content.trim();
const isVerified = captchaVerifier.verifyCaptcha(userInput);
if (isVerified) {
message.reply('Captcha verified successfully!');
}
});
client.login('YOUR_BOT_TOKEN');
Replace ('YOUR_BOT_TOKEN') with your Discord bot token.
Methods
'sendCaptchaMessage(channel)' Sends the generated captcha code to the specified channel.
Parameters:
channel (Discord.js Channel): The channel to send the captcha message. verifyCaptcha(userInput) Verifies if the provided user input matches the generated captcha code.
Parameters:
userInput (String): The user's input to be verified.
Returns:
true if the input is correct, false otherwise.