0

I use db.push(message.author.id), "item" for doing this.

This is for making a game but I want it to not running the code if the user does not own that specific item.

cinoez
  • 33
  • 1
  • 5

1 Answers1

0

Use db.has(message.author.id + '.items.weapons') for examlple

You can see more in the npm website

What you did :

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

And what you should do to see if the element exists

db.has(message.author.id + '.items')
  • try like this maybe : `if(db.has(message.author.id + '.items')) message.channel.send('You do have items ! Here are they : ${db.get(message.author.id + '.items')).join(' - ')` And if it didn't work please give me what you want so i can be specific ^^ – 87message.author.username7 Sep 15 '20 at 10:10
  • Oh i didn't want to do that what i want is like `let item = db.has(message.author.id, desc) if(item) {a long long code here}` (desc = `${itemName}\n ${itemCat} - ${sellPrice}`) This code doesn't work – cinoez Sep 15 '20 at 10:15
  • hmm.. seems like i need a little bit more. add me as a friend so i can explain u better ^^' If you can here is my tag : ♫ ฅ^✯-✯^ฅ ♪#3526 – 87message.author.username7 Sep 15 '20 at 10:30
  • epic, now everything is fixed uvu – 87message.author.username7 Sep 15 '20 at 11:07