您好,我正在尝试让验证码验证机器人是否正常运行。 但是我收到此错误:(node:1053)UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性“ set”
在Object.module.exports.run(/app/commands/verify.js:29:15)
代码(verify.js):
const discord = require("discord.js");
const config = require("../config.json");
const { randomBytes } = require("crypto");
const Jimp = require("jimp");
const { RichEmbed } = require("discord.js");
module.exports.run = async (bot, message, args) => {
if (message.channel.id === 650471853495681085) {
const captcha = randomBytes(32).toString("hex").substr(0, 6);
const font = await Jimp.loadFont(Jimp.FONT_SANS_64_BLACK);
const image = await Jimp.read("../assets/vrf.jpg");
image.print(font, 0, 0, captcha);
const buffer = await image.getBufferAsync(Jimp.MIME_JPEG);
const embed = new RichEmbed()
.setTitle("Verification")
.setDescription("please do !verify for verification")
.attachFile({ attachment: buffer, name: "captcha.jpeg" })
.setImage("attachment://captcha.jpeg");
message.author.send(embed).catch(() => {
message.reply("Direct messages disabled");
});
this.query.set(message.author.id, captcha);
} else {
// Arguments provided
if (!this.query.has(message.author.id)) return message.reply("Request captcha by sending !verify");
const captcha = this.query.get(message.author.id);
if (message.args[0] !== captcha) return message.reply("Invalid captcha!");
else {
message.member.addRole(this.config.verifyRole).then(() => {
message.reply("Successfully verified.");
}).catch(console.error);
this.query.delete(message.author.id);
}
}
};
module.exports.help = {
name:"verify"
};
我们将不胜感激。 如果有人可以帮助我,那将是很好。是的