How in json can cooldown be made? For example, I have a VKontakte bot, and the "bonus" command, I need to make sure that when the second "bonus" command is sent, the user is sent the message "Wait 4 hours"! How can you make such a delay?

elseif($body[0] == 'бонус' || $body[0] == 'Бонус'){ $from_id = $this->conf->data->object->from_id; $UserData = json_decode(file_get_contents('users.json'), true); if(!isset($UserData[$from_id]['bonus'])){ $UserData[$from_id]['balance'] += 3500; $UserData[$from_id]['bonus'] = 'used'; file_put_contents('users.json', json_encode($UserData)); $self = "👤$nick".", \n\n✅Вы получили бонус 3500$! Баланс: {$UserData[$from_id]['balance']}$"; }else{ $self = "👤$nick".", \n\n❎Вы уже использовали бонус!"; } } 
  • It is not clear what you mean - ArchDemon
  • Want to make a delay that is not understandable? - Amin Aliyev
  • one
    Save in the database the date-time of the last "bonus" to the user. And check with the request - if 4 hours has not passed, then give nothing. - AivanF.
  • Can I please in the code? I study php for no more than 2 weeks. - Amin Aliyev

0