验证码不适合我的不和谐机器人



我一直在尝试在我的聊天机器人上设置验证码。我对JavaScript完全陌生,我正在努力理解这些问题。但是,这不是重点。当我在聊天中进行"I -verification"时,它不起作用。它也不记录任何东西。它只是不做任何事情,没有错误。

代码:

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('');

将函数放入if语句中。我很确定你做不到。要么将函数放在语句外,要么将内容放在if语句内。

我会在你的dm中进一步解释:)

最新更新