repository = $repository; } /** * Send a command to a running server. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\SendCommandRequest $request * @return \Illuminate\Http\Response * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function index(SendCommandRequest $request): Response { $server = $request->getModel(Server::class); try { $this->repository->setServer($server)->send($request->input('command')); } catch (RequestException $exception) { if ($exception instanceof BadResponseException) { if ( $exception->getResponse() instanceof ResponseInterface && $exception->getResponse()->getStatusCode() === Response::HTTP_BAD_GATEWAY ) { throw new HttpException( Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception ); } } throw new DaemonConnectionException($exception); } return $this->returnNoContent(); } }