How would I make it so when I use a command it adds a timer and that timer would end I'm 30 days! And if someone tries to use that command during that time it would send a message saying timer is going on.
you can use time()+30days in second and set it on config if the time() is lesser then config, it meant the cooldown is still ongoing
if you want the code: PHP: public $config; //Make you sure to add this and create a new Config() when server is enabled/*** @param string $command* @param int $delay*/public function addTimer(string $command, int $delay){ if($this->config instanceof Config) { $this->config->set($command, $delay + time()); } else { $this->config = new Config($this->getDataFolder() . "timers.json", Config::JSON); $this->config->set($command, $delay + time()); }}/*** @param string $command* @return int*/public function getTimer(string $command) : int{ if($this->config instanceof Config) { if($this->config->exists($command)){ return $this->config->get($command); } return 0; } else { $this->config = new Config($this->getDataFolder() . "timers.json", Config::JSON); if($this->config->exists($command)){ return $this->config->get($command); } return 0; }}
Assuming the code you provided is for the main class, it can be made better with this: PHP: /** * @param string $command * @param int $delay */public function addTimer(string $command, int $delay) : void { $this->getConfig()->set($command, $delay + time()); $this->getConfig()->save();}/** * @param string $command * * @return int|null */public function getTimer(string $command) : ?int { return $this->config->get($command, null);}