所以我最近在 discord js 中使用 warn 命令制作了这段代码,但是有一个问题,我的 if 语句不能像我想要的那样工作,如果值不存在,我希望它是 return message.channel.send("该用户没有记录!"); 因为我从未尝试过在 javascript 上使用 sqlite,而且我只知道在 c# 上使用 sqlite
const con = require("../../sql.js");
con.all(`SELECT * FROM warnings WHERE username = ? AND userID = ?`, User.tag, User.id, (err, rows) => {
rows.forEach(r => {
if (!rows) {
message.channel.send("NO U");
}
else {
let moderator = (r.moderator);
let modID = (r.modID);
let reason = (r.reason);
let time = (r.time);
let Avatar = User.displayAvatarURL();
let Embed = new MessageEmbed()
.setTitle(`User warnings!`)
.setDescription(
`These is all the warnings which have been issued to ${User.tag}!`)
.setColor(`RED`)
.setThumbnail(Avatar)
.addFields({
name: "Moderator",
value: `${moderator}`,
inline: true
}, {
name: "Username",
value: `${User.tag}`,
inline: true
}, {
name: "Reason",
value: `${reason}`,
inline: true
}, {
name: "When was warned",
value: `${time}`,
inline: true,
});
message.channel.send(Embed).then(msg => {
msg.delete({
timeout: 15000
});
message.delete({
timeout: 3000
});
})
}
})
})
慕标琳琳
白猪掌柜的
相关分类