i'm making a Telegram bot using php language, i want to add a cooldown to a command, i already tried with sleep(), but the result still the same, it doesn't work, someone can help me? At least this is possible? or i need to re code the bot in another language?
here the code:
<?php
namespace Longman\TelegramBot\Commands\UserCommands;
use Longman\TelegramBot\Commands\UserCommand;
use Longman\TelegramBot\Request;
class DiscordCommand extends UserCommand{
protected $name = 'discord';
protected $description = 'Linka server discord';
protected $usage = '/discord';
protected $version = '1.0.0';
public function execute()
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$message_id = $message->getMessageId();
$text = 'Ciaoo';
$data = [
'chat_id' => $chat_id,
'text' => $text];
$started_at = time();
if($current_time==$started_at)
return Request::sendMessage($data);
$cooldown = 60*60*1; //1 minutes
$current_time = time();
$timeLeft = $current_time - $started_at;
if($timeLeft >= $cooldown)
return Request::sendMessage($data);