diff --git a/app/Jobs/RunBot.php b/app/Jobs/RunBot.php new file mode 100644 index 0000000..674a25b --- /dev/null +++ b/app/Jobs/RunBot.php @@ -0,0 +1,29 @@ +bot->class($this->bot->config ?? []); + + $class->run(); + } +} diff --git a/app/Livewire/BotsList.php b/app/Livewire/BotsList.php index c1c331c..1a2cdc4 100644 --- a/app/Livewire/BotsList.php +++ b/app/Livewire/BotsList.php @@ -2,6 +2,7 @@ namespace App\Livewire; +use App\Jobs\RunBot; use App\Models\Bot; use Illuminate\Support\Facades\Auth; use Jantinnerezo\LivewireAlert\Facades\LivewireAlert; @@ -62,9 +63,7 @@ class BotsList extends Component public function confirmRunBot(Bot $bot): void { // Dispatch the job to run the bot - $class = new $bot->class($bot->config ?? []); - - $class->run(); + dispatch(new RunBot($bot)); flash()->success("Bot '{$bot->name}' is being executed."); }