He estado tratando de hacer un captcha en mi bot de discordia. Soy completamente nuevo en JavaScript y me cuesta entender los problemas. Pero, ese no es el punto. Cuando hago 'ri-verification' en el chat, no funciona. Tampoco registra nada. Simplemente no hace nada sin errores.
Código:
const Discord = require('discord.js-12'); const client = new Discord.Client(); const prefix = 'ri-'; const Captcha = require("@haileybot/captcha-generator"); client.once('ready', () => { console.log('Ready!'); }); let captcha = new Captcha(); console.log(captcha.value); const path = require("path"), fs = require("fs") captcha.PNGStream.pipe(fs.createWriteStream(path.join(__dirname, `${captcha.value}.png`))); captcha.JPEGStream.pipe(fs.createWriteStream(path.join(__dirname, `${captcha.value}.jpeg`))); client.on('message', async message => { if (!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content.slice(prefix.length).trim().split(/ +/); const command = args.shift().toLowerCase(); if (command === 'verification') { function verifyHuman(msg) { let captcha = new Captcha(); msg.channel.send( "**Enter the text shown in the image below:**", new Discord.MessageAttachment(captcha.JPEGStream, "captcha.jpeg") ); let collector = msg.channel.createMessageCollector(m => m.author.id === msg.author.id); collector.on("collect", m => { if (m.content.toUpperCase() === captcha.value) msg.channel.send("Verified Successfully!"); else msg.channel.send("Failed Verification!"); collector.stop(); }); }; } }); client.login('');Está poniendo una función dentro de una declaración if. Seguro que no puedes hacer eso. Coloque la función fuera de la declaración o coloque el contenido dentro de ella en la declaración if.
Te lo explicaré más en tus DM :)