有没有一种方法可以检查用户在quick.db中是否有特定项目

时间:2020-09-15 09:45:13

标签: node.js database discord.js quick.db

我使用db.push(message.author.id), "item"来做到这一点。

这是为了制作游戏,但是如果用户不拥有该特定物品,我希望它不运行代码。

1 个答案:

答案 0 :(得分:0)

使用db.has(message.author.id + '.items.weapons')例如

您可以在npm website

中看到更多信息

您做了什么:

// Pushing an element to an array (that doesn't exist yet) in an object:
db.push(message.author.id + '.items', 'Sword')
// -> { items: ['Sword'] }

该怎么做才能查看元素是否存在

db.has(message.author.id + '.items')