Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
The captcha is not working for my Discord bot

I have been trying to make a captcha on my discord bot. I am entirely new to JavaScript and I'm struggling to understand the issues. But, that's not the point. When I do 'ri-verification' on the chat, it does not work. It doesn't log anything either. It just does nothing with no errors.

Code:

    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('');
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are putting a function inside an if statement. Pretty sure you cannot do that. Either put the function outside the statement or put the contents inside it in the if statement.

I'll explain it further in your DMs :)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda