我使用db.push(message.author.id), "item"
来做到这一点。
这是为了制作游戏,但是如果用户不拥有该特定物品,我希望它不运行代码。
答案 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')