Answer the question
In order to leave comments, you need to log in
What to do: Error processing command in vk bot, node js?
Help me please!
I am writing a vk game bot (like Bot Gorilla), vk-io library, node js.
An error occurs while processing one of the commands. The bot starts normally, the command just doesn't work.
updates.hear(/статистика$/i,(context) => {
let platform = false
if(context.isChat) platform = true
let user = base.bs[base.id[context.senderId].id]
let nick = ``
if(user.nicknotify == false) {
nick = `${base.bs[base.id[context.senderId].id].nick}`
}
if(user.nicknotify == true) {
nick = `*id${context.senderId} (${base.bs[base.id[context.senderId].id].nick})`
}
let myclan = clan[base.bs[base.id[context.senderId].id].clan]
let top = []
let topenab = []
let btc = []
if(user.rank < 4) return
let blocked = 0
for(let b in base.bs){
if(base.bs[b].banned == true){
blocked += Number(1)
}
}
let balance = 0
for(let a in base.bs){
balance += Number(base.bs[a].balance)
}
let bank = 0
let farms = 0
let rate = 0
for(let i in base.bs){
if(base.bs[i].btc !== 0 || base.bs[i].btc !== null || base.bs[i].btc !== undefined){
btc.push({
id: base.bs[i].id,
balance: base.bs[i].btc
})
}
}
for(let n in base.bs){
bank += Number(base.bs[n].bank)
farms += Number(base.bs[n].farms)
rate += Number(base.bs[n].rating)
}
for(let i in base.bs){
if(base.bs[i].topenabled == false){
top.push({
id: base.bs[i].id,
balance: base.bs[i].balance
})
}
if(base.bs[i].topenabled == true){
topenab.push({
id: base.bs[i].id,
balance: base.bs[i].balance
})
}
}
top.sort(function(a, b) {
if (b.balance > a.balance) return 1
if (b.balance < a.balance) return -1
return 0
});
btc.sort(function(a, b) {
if (b.balance > a.balance) return 1
if (b.balance < a.balance) return -1
return 0
});
topenab.sort(function(a, b) {
if (b.balance > a.balance) return 1
if (b.balance < a.balance) return -1
return 0
});
return context.send(`Статистика:
Всего игроков: ${base.context.id}
⛔ Заблокировано: ${blocked}
Сумма всех денег игроков: ${utils.sp(balance)}$
Сумма всех денег в банке игроков: ${utils.sp(bank)}$
Сумма всех ферм игроков: ${utils.sp(farms)}
Сумма всего рейтинга игроков: ${utils.sp(rate)}
Самый богатый игрок[TOPFALSE]: *id${top[0].id} (${base.bs[base.id[top[0].id].id].nick}) (${base.id[top[0].id].id}) >> ${utils.sp(top[0].balance)}$
Самый богатый игрок[TOPTRUE]: *id${topenab[0].id} (${base.bs[base.id[topenab[0].id].id].nick}) (${base.id[topenab[0].id].id}) >> ${utils.sp(topenab[0].balance)}$
Самое большое кол-во биткоинов у: *id${btc[0].id} (${base.bs[base.id[btc[0].id].id].nick}) (${base.id[btc[0].id].id}) >> ${utils.sp(btc[0].balance)}
`)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question