K
K
Kropovniczky2021-11-16 20:09:18
JavaScript
Kropovniczky, 2021-11-16 20:09:18

Timeout issues?

let time = rand(5,20)
    let time1 = time * 1000
    let time2 = time1 / 1000
    user.balance += rybes;
    if (user.job >= 1){ 
      return msg.send (`Ваш персонаж всё еще работает.`)
    } 
    else if (user.job <= 0){
      user.job += 1
      user.save()
     msg.send(`Ваш персонаж начал работу, время работы составляет ${time} секунд.`)
     setTimeout (() =>{
      msg.send(`${randomSmile} Вы закончили работать и заработали: ${rybes}\n---Для просмотра баланса пишите: Баланс`)
    }, time1)
  }
  user.job -= 1
});


As a result, the bot does not see the first condition, because +job is not added after writing the command (i.e. the bot always starts working then after the timeout it writes the speed I earned, but even if 2 messages per second are written, it still will not see the limit works)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Nedzvetsky, 2021-11-22
@Nezd

In the penultimate line, the job is subtracted in any case, probably the problem is this.
user.job -= 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question