我正在尝试创建一条命令,如果查询匹配的'characterName'与'msgArgs1'相匹配,那么我想返回匹配的文档的其他值,但它给我错误,例如'characterID'未定义>
我的代码:
const mongoose = require('mongoose');
mongoose.connect('mongodb+srv://Owner:@cluster0-umjcr.mongodb.net/Justice_Bot?retryWrites=true&w=majority',{
useNewUrlParser: true,
useUnifiedTopology: true
});
const Character = require("../models/character");
module.exports.run = async(client, message, cmdArgs, argss) => {
let msgArgs1 = argss.slice(1).join(" ");
let p = Character.findOne({
characterName: msgArgs1
}, (characterID, characterName, originalName, type, link, Intelligence, Strength, Speed, Durability , Power ,Combat) => {
if (p) {
let info = new MessageEmbed()
.setDescription(`**#${characterID.characterID} ${JSON.stringify.characterName}**`)
.setDescription(`Name: ${JSON.stringify.originalName} Type: ${type}`)
.addField('Intelligence: ', Intelligence.Intelligence, true)
.addField('Strength: ', Strength.Strength, true )
.addField('Speed: ', Speed.Speed, true)
.addField('Durability: ', Durability.Durability, true)
.addField('Power: ', Power.Power, true)
.addField('Combat: ', Combat.Combat, true)
.setImage(JSON.stringify.link, true)
.setColor(0xE3C910)
message.channel.send(info);
}else return message.channel.send("character Not found!")
})
}```