有没有办法检查用户是否在 quick.db 中有特定项目
Is there a way to check if user has a specific item in 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')
我用 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')