Skip to content

Commit

Permalink
Don't show passengers in status driver command when no passengers joined
Browse files Browse the repository at this point in the history
  • Loading branch information
Korbeil committed May 15, 2024
1 parent dfe3a39 commit c76663d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/src/Discord/Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,20 @@ public function callback(Discord $discord): void
$status .= $this->translator->trans('discord.status.row_not_driver', ['driver_id' => $traveler->transport->getDriver()->userId]);
} else {
$sharedWith = [];
$passengerCount = 0;
foreach ($traveler->transport->getPassengers() as $passenger) {
$sharedWith[] = sprintf('<@%d>', $passenger->user->userId);
++$passengerCount;
}

$status .= $this->translator->trans('discord.status.row_driver', ['seats_remaining' => $traveler->transport->availableSeats(), 'seats_total' => $traveler->transport->seats, 'travelers' => implode(', ', $sharedWith)]);
$translationKey = 'discord.status.row_driver_no_passengers';
$translationData = ['seats_remaining' => $traveler->transport->availableSeats(), 'seats_total' => $traveler->transport->seats];
if ($passengerCount > 0) {
$translationKey = 'discord.status.row_driver';
$translationData['travelers'] = implode(', ', $sharedWith);
}

$status .= $this->translator->trans($translationKey, $translationData);
}

$content .= $status . "\n";
Expand Down
1 change: 1 addition & 0 deletions app/translations/messages+intl-icu.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
'row' => '- [{traveler_type}] Leaving at {hour} on {date} from {postal_code}',
'row_not_driver' => ' (transported by <@{driver_id}>)',
'row_driver' => ' ({seats_remaining}/{seats_total} passenger seats available, including {travelers})',
'row_driver_no_passengers' => ' ({seats_remaining}/{seats_total} passenger seats available',
'empty' => 'You have not registered in any transport for "{name}" event.',
],
],
Expand Down
1 change: 1 addition & 0 deletions app/translations/messages+intl-icu.fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
'row' => '- [{traveler_type}] Part à {hour} le {date} depuis {postal_code}',
'row_not_driver' => ' (conduit par <@{driver_id}>)',
'row_driver' => ' ({seats_remaining}/{seats_total} places disponibles, dont {travelers})',
'row_driver_no_passengers' => ' ({seats_remaining}/{seats_total} places disponibles)',
'empty' => 'Vous n’êtes enregistré·e dans aucun transport pour l’événement "{name}".',
],
],
Expand Down

0 comments on commit c76663d

Please sign in to comment.