Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在用打字稿写一个不和谐的机器人,似乎无法检索数据。我可以在 JSON.sqlite 文件中看到用户 ID,但我无法弄清楚为什么null在检索数据时它会返回。如果您想查看我的代码,我在Pastebin上有一些评论。
null
线
console.log(economy.get(`${msg.author.id}.money`))
是错的。你可能想要
console.log(economy.get(msg.author.id).money)
原因: ${}正在制作一个模板字符串,它确实将变量放入一个字符串中,但是,您不需要这样做,因为首先传入值会这样做。但是,您正在尝试从 访问该money属性msg.author_id,该属性不存在。因此,它返回 null 并且 SQLite 找不到null条目。
${}
money
msg.author_id