In my attempt to create a bot in discord.js, I am facing a challenge where I need to implement an inventory system with items that have durability. The data is stored in MongoDB Atlas and the structure of the inventory is as follows:
user: {
id: 'user-id',
name: 'user-name',
inventory: [
{
name: 'item',
durability: 5
,
{
name: 'another-item',
durability: 20
}
]
}
I am looking for a way to decrement the durability of an item in the inventory without affecting any other items in the array, but I haven't been able to find a solution so far.