🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-20 17:11:21 +01:00
parent a628b140c1
commit d3ef41c9dd
7 changed files with 97 additions and 16 deletions
+32
View File
@@ -275,4 +275,36 @@ class RconService
{
$this->closeConnection();
}
public function sendSafelyFromDashboard(string $action, array $args, string $errorMessage): void
{
try {
switch ($action) {
case 'sendBadge':
/** @var \App\Models\User $user */
$user = $args[0];
/** @var string $badge */
$badge = (string) ($args[1] ?? '');
$this->giveBadge($user, $badge);
break;
case 'removeBadge':
// No direct RCON command defined for removing badges; use alert for now
/** @var \App\Models\User $user */
$user = $args[0];
/** @var string $badge */
$badge = (string) ($args[1] ?? '');
$this->alertUser($user, sprintf('Badge %s removed.', $badge));
break;
default:
break;
}
} catch (\Throwable $e) {
\Filament\Notifications\Notification::make()
->danger()
->title('RCON Error')
->body($errorMessage)
->persistent()
->send();
}
}
}