How do I cancel a task when I do a command? For example run this command: PHP: $task = new DiscoTask($this, $sender->getName());$this->getScheduler()->cancelTask($task->getTaskId()); It does nothing. Any idea how to get it working?
[Server thread/CRITICAL]: Error: "Call to undefined method TestPlugin\DiscoTask::cancel()" That doesn't work
What you did here is schedule the task a second time, and then cancel this second one. What you would have to do is save the task id within an array on schedule of the task, then cancel the task with id of the one in array
Spoiler: Example PHP: public $taskIds = [];/* Schedule your task here*/$this->taskIds["task"] = $task->getTaskId();/* You want to cancel your task*/$this->getScheduler()->cancelTask($this->taskIds["task"]);