From 1ba6126a88aa6b47f225c9f76879e6fd09be401e Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Wed, 21 Aug 2024 00:32:36 +1000 Subject: [PATCH] Update ProcessSessionLogging.php --- app/Jobs/ProcessSessionLogging.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/app/Jobs/ProcessSessionLogging.php b/app/Jobs/ProcessSessionLogging.php index 4b068324..49465612 100644 --- a/app/Jobs/ProcessSessionLogging.php +++ b/app/Jobs/ProcessSessionLogging.php @@ -70,11 +70,16 @@ public function handle() } if($session->discord_id == null){ - $discord = new DiscordClient(); - $discord_id = $discord->ControllerConnection($controller->callsign, $name); - - $session->discord_id = $discord_id; - $session->save(); + try{ + $discord = new DiscordClient(); + $discord_id = $discord->ControllerConnection($controller->callsign, $name); + + $session->discord_id = $discord_id; + $session->save(); + } catch (\Exception $e) { + $discord = new DiscordClient(); + $discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'Discord Controller Connect Error', $e->getMessage()); + } } array_push($positionsFound, $controller->callsign); @@ -98,13 +103,18 @@ public function handle() } if($log->discord_id !== null){ - $discord = new DiscordClient(); - $data = $discord->ControllerDisconnect($log->discord_id, $log->callsign, $name, $log->session_start, $log->duration); - - $log->discord_id = null; - $log->save; + try{ + $discord = new DiscordClient(); + $data = $discord->ControllerDisconnect($log->discord_id, $log->callsign, $name, $log->session_start, $log->duration); + } catch (\Exception $e) { + $discord = new DiscordClient(); + $discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'Discord Controller Disconnect Error', $e->getMessage()); + } } + $log->discord_id = null; + $log->save; + //If there is an associated roster member, give them the hours if ($rosterMember = $log->rosterMember) { if (($rosterMember->certification == 'certified' || $rosterMember->certification == 'training') && $rosterMember->active) {