way.on("messageCreate",(letter)=>{
if(!letter.author.bot) {
//кто отправил
sender = letter.author.id
//внесение в бд
db.query(`SELECT * FROM inventory WHERE who=?`,[creator],function (bad,good,trash){
if(typeof(good[0])=="undefined"){
db.query(`INSERT INTO inventory VALUES(?,?,?)`,[creator,10,"[]"])
}
})
//тут же обратиться к бд
db.get(`SELECT * FROM inventory WHERE who=${sender}`,function (mistake,complete){
after=""
before=JSON.parse(complete.bag)
if(before.length){
for(slot=0;slot<before.length;slot++){
after+=`\nслот [${slot+1}] содержит [${before[slot]}]`
}
}
calc = ((before.length/complete.capacity)*100).toFixed(0)
letter.channel.send("```"+`рюкзак заполнен на ${calc}%\n======================= ${after}`+"```")
}
}
way.on("messageCreate",(letter)=> {
if (!letter.author.bot) {
//кто отправил
sender = letter.author.id
//внесение в бд
db.query(`SELECT * FROM inventory WHERE who = ?`, [creator], function (bad, good, trash) {
if (typeof (good[0]) == "undefined") {
db.query(`INSERT INTO inventory VALUES (?, ?, ?)`, [creator, 10, "[]"])
//тут же обратиться к бд
db.get(`SELECT * FROM inventory WHERE who = ${sender}`, function (mistake, complete) {
after = ""
before = JSON.parse(complete.bag)
if (before.length) {
for (slot = 0; slot < before.length; slot++) {
after += `\nслот [${slot + 1}] содержит [${before[slot]}]`
}
}
calc = ((before.length / complete.capacity) * 100).toFixed(0)
letter.channel.send("```" + `рюкзак заполнен на ${calc}%\n======================= ${after}` + "```")
})
}
})
}
})