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

问题描述

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

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

解决方法

使用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')