I have an array that contains several anime characters, and I am using a db to store which ones you have like this:
var your_chars = '2,5,7,93'
u have the chars with this numbers! json/array:
"all_units":[
{
"name":"",
"anime":"",
"star":"0",
"image":""
},
{
"name":"Naruto Uzumaki",
"anime":"Naruto",
"star":"2",
"image":""
},
{
"name":"Son Goku",
"anime":"Dragon Ball",
"star":"2",
"image":""
},
{
"name":"Monkey D. Luffy",
"anime":"One Piece",
"star":"2",
"image":""
},
{
"name":"Naruto Uzumaki (Sage Mode)",
"anime":"Naruto",
"star":"4",
"image":""
}
]
so if u have char 2, u have naruto uzumaki. but I want to make a list of all units you have (being possible to see name and stars) like this:
[2] - Son Goku (2)
[4] - Naruto Uzumaki Sage (4)
[{numer in array}] - {name} - ({stars})
I tried it using 'for(){}' but I didn't get much result :(
summarizing my goal: make a list of chars I own (var in your_chars) and print it
my last try:
(async()=>{
var fs = require('fs');
var item = JSON.parse(fs.readFileSync("./utils/itens.json", "utf-8"));//heres json archive
let u = await client.db.get("main", "charsOwned_{user ID}");//this returns: "value":"2,5,6,1"
let chars = u.value
let list = ''
for(i = 0; i < 30;i++){
if(chars[i]){
let c = item.all_units[i].name
let n_s = item.all_units[i].star
let s = '<:s_:813141250911633438>';
list = list + `\n**[\${i}]**・\${c} \${s.repeat(n_s)}`
}
}
console.log(lista)
})()
for(){}won't give you the results like that. Can you show us your actual attempt?[2]corespond toSon Gokuu.value.split(/,/g)