This might be a pretty simple solution but I am really lost with it. In my discord economy bot, I have fully developed an inventory system - where user can buy items from the shop, store them in their inventory and use them at will. The simple problem I am facing is when the user has two items of the same kind (for example - like car) , the items will show up in their inventory twice like- car car
instead of it, I want the embed to be shown as- car x2
I am thinking about using loops but I am not sure if I am doing the right way. I can continue if I get a general idea of how to implement it! Please help me!!
The following is my simplified items command!
const db = require ('quick.db')
const Discord = require ('discord.js')
module.exports = {
commands : ["items","i"],
alias : ["i"],
callback : async (message,arguments,text) => {
const target = message.mentions.members.first () || message.author
let items = db.fetch (`itm_${target.id}`)
if (items === null || !items[0]) (items = "No items here")
const embed = new Discord.MessageEmbed ()
.setTitle (`${target}'s items`)
.addFields (
{name : "items", value:items}
)
.setColor ("#ECB802")
message.channel.send (embed)
}
}