#captcha

1 messages · Page 1 of 1 (latest)

lean minnow
#

@versed trench

#

It is not very complicated

#

So

#

The main idea is to verify users after passing the captcha code

versed trench
#

Mhm

#

So

craggy juniper
#

so you just give the user a role when they complete the captcha?

lean minnow
#

When a user logs on to the server, a picture with a code is sent to the chat

lean minnow
versed trench
#
const code = your code
const userCode = code user sent


if (code === userCode) {
   // Your stuff
} else {
// Your other stuff
}
lean minnow
#

No

#

With slash-commands

lean minnow
#

If the code is correct, authorization occurs, otherwise a new picture is sent

torn gyro
#

What’s your question? How to get the code that the user inputted?

lean minnow
#

How to use interactions properly

lean minnow
lean minnow
#

Wait

torn gyro
lean minnow
#
client.on("interactionCreate", async interaction => {
        if(interaction.isCommand() && interaction.commandName == "captcha") {
            const code = interaction.options.getString("code")
            const author = interaction.user

            if(code == null) {
                let [text, image] = await captcha();
                interaction.reply({
                    content: "Use /captcha [code]",
                    files: [
                        new Discord.MessageAttachment(image, "captcha.png")
                    ],
                    ephemeral: true
                })

                captches[author.id] = text
            } else {
                if(captches[author.id] != code) {
                    interaction.reply({
                        content: "Captcha is wrong. Use /captcha",
                        ephemeral: true
                    })

                    if(captches[author.id] != undefined)
                        delete captches[author.id];
                } else {
                    return interaction.reply({
                        content: "Authorized",
                        ephemeral: true
                    })
                }
            }
        }
    });
#

This one

lean minnow
#

Have you ever done a captcha?

versed trench
#

Ofc

#

I just got the captcha from some API

lean minnow
#

ok

versed trench
#

Then conpared one I got with one user sent

#

& if else did the rest work :)

torn gyro
#

Do you have a question relating to discordjs? @lean minnow

versed trench
#

Just like OTP verifying

lean minnow
#

How to use interactions correclty

versed trench
lean minnow
#

?

torn gyro
#

I’ve already sent you a link to the guide

lean minnow
#

It's not clear

craggy juniper
#

so what you're trying to do is to send a msg in a channel when guildMemberAdd and the user uses an interaction to fill up the captcha you just sent in the guildMemberAdd event?

lean minnow
torn gyro
#

Whats the error

lean minnow
#

Native discord error

torn gyro
#

can you show us the original error?

lean minnow
#

To sum up

When logging in, a message with a picture is sent to the user - the usual one, visible to all users

using /captcha [code], the user enters the code from the image. From this moment the interaction begins

If the code is correct, the bot authorizes the user
If the code is incorrect, the bot sends a new code

#

@versed trench can u help?

versed trench
#

Um

#

I just told what to do

lean minnow
#

use api?