listenCommand('infovehicul', function (Interaction $interaction) { $options = $interaction->data->options; $parc = $options['numarparc']->value; $client = new \GuzzleHttp\Client(); $request = $client->request('GET', 'https://maps.mo-bi.ro/api/passenger-data'); if ($request->getStatusCode() !== 200) { $interaction->respondWithMessage( MessageBuilder::new()->setContent( 'OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this' ) ); return true; } $response = json_decode($request->getBody(), true); $vehicle = null; foreach ($response as $v) { if ($v['vehicle_id'] == $parc) { $vehicle = $v; break; } } if (!$vehicle) { $interaction->respondWithMessage( MessageBuilder::new()->setContent( 'Vehiculul nu a putut fi gasit. Tineti cont ca doar vehiculele achizitionate dupa 2018 merg cu aceasta comanda.' ) ); return true; } $destination = $vehicle['destination'] ?? "N/A"; $peopleOnBoard = $vehicle['people_on_board'] ?? "Unknown"; $interactionResponse = "__**" . $parc . "** " . $destination . "__\nOameni in vehicul: " . $peopleOnBoard . "\n\n"; $crt = 1; foreach ($vehicle['apc_sensors'] as $sensor) { if ($sensor["device_online"]) { $door = "Nu"; if ($sensor['door_open']) { $door = "Da"; } $interactionResponse = $interactionResponse . "**Senzor " . $crt . "**: Usa deschisa? " . $door . " // Intrari: " . $sensor['entries'] . " // Iesiri: " . $sensor['exits'] . "\n"; $crt++; } } $interaction->respondWithMessage( MessageBuilder::new()->setContent($interactionResponse) ); }); ?>