我有一个从mysql服务器获取到期日期的功能,并将该日期与其他信息一起保存在mongodb上, 但是运行后,除日期外所有内容都会保存。
功能:
const sql = "SELECT expiry from membri where pass = '" + license + "'"
function expiry(license, callback, results){
con.query(sql, results)
if (results) {
callback(results[0].expiry)
}
}
保存数据
const newUser = new User({
userKey: license,
authenicated: true,
discordUserID: discordUserID,
currentDate: new Date(),
expiredDate: new expiry(license)
});
console.log(new Date())
// save user
newUser
.save()
.then(() => {
const member = guild.member(msg.author);
if (member) {
// after successfully authenicated, give user role => access for only 30 days
member.addRole(memberRoleID);
const successEmbed = new Discord.RichEmbed()
.setAuthor("Authentication Bot ( SUCCESS )")
.setColor("#9b42f4")
.addField(
"Activated: ",
`${license} :white_check_mark:`
);
return msg.author.send(successEmbed);
}
})
[...]
感谢帮助!