gpt4 book ai didi

javascript - 获取多行返回 Undefined Sequelize

转载 作者:行者123 更新时间:2023-12-03 22:18:59 26 4
gpt4 key购买 nike

我正在尝试使用 Discord.JS 和 Sequelize 为不和谐机器人编写警告系统。保存警告有效,但提取无效。

async function warnGet() {
let msgArgs = message.content.split(" ");
var ReportID = Math.floor(1000 + Math.random() * 9000);
let messageReason = msgArgs[2]
? message.content.substring(
msgArgs.slice(0, 3).join(" ").length + 1
)
: "No reason provided";
(async () => {
try {
let userTag = member.user.tag;
let warningYes = JSON.stringify(
await moderationLogging.findAll({
where: {
Member: userTag,
},
}),
{ raw: true }
);
warningYes = JSON.parse(warningYes);
const faqembed = new MessageEmbed()
.setColor("#ff9100")
.addField(
`Reason: ${warningYes.Reason}`,
`Report ID: ${warningYes.ReprtID}`
)
.setAuthor(
member.user.username,
member.user.displayAvatarURL({
format: "jpg",
dynamic: "true",
})
);
warningYes.forEach((e) => {
faqembed.addField(
`Reason: ${warningYes.Reason}`,
`Report ID: ${warningYes.ReprtID}`
);
});
message.channel.send(faqembed);
} catch (error) {
message.channel.send(
`Aw maaaaan. I couldn't do the thing I needed to do. <@388813100964642816> should prob know about this. The technical stuff\` \`\`\`xl\n${clean(
error
)}\n\`\`\``
);
console.log(error);
}
})();
}
运行时此代码返回此代码
This leads to the result.
我不知道为什么。任何帮助,将不胜感激。
这些是它试图获取 Image 的条目

最佳答案

更新!所以,我实际上是自己解决的!而不是做

               warningYes = JSON.parse(warningYes);
const faqembed = new MessageEmbed()
.setColor("#ff9100")
.addField(
`Reason: ${warningYes.Reason}`,
`Report ID: ${warningYes.ReprtID}`
)
我做了这个
                const warning = JSON.parse(warningYes);
const faqembed = new MessageEmbed()
.setColor("#ff9100")
.addField(
`Reason: ${warning[0].Reason}`,
`Report ID: ${warning[0].ReprtID}`
)
.setAuthor(
member.user.username,
member.user.displayAvatarURL({
format: "jpg",
dynamic: "true",
})
);
如果您需要知道,我在它的末尾添加了一个 [0]。原来这就是我所需要的。现在已经修复了,所以是的!

关于javascript - 获取多行返回 Undefined Sequelize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67111561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com