From 6a29fa93778e3981959450dfa4d0d2e6ef122f6c Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Mon, 19 Aug 2024 06:04:25 +1000 Subject: [PATCH] TestAgain2 --- app/Console/Kernel.php | 2 +- app/Jobs/DiscordTrainingUpdates.php | 78 ++++++++++++++--------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f34e5fd0..f55f928a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -106,7 +106,7 @@ protected function schedule(Schedule $schedule) $schedule->job(new ProcessSessionReminders())->daily(); // Check Training Threads Status (Once per week) - $schedule->job(new DiscordTrainingUpdates())->weeklyOn(7, '20:03'); + $schedule->job(new DiscordTrainingUpdates())->weeklyOn(7, '20:06'); // Discord role updating //$schedule->job(new UpdateDiscordUserRoles)->twiceDaily(6, 18); diff --git a/app/Jobs/DiscordTrainingUpdates.php b/app/Jobs/DiscordTrainingUpdates.php index 37c5c883..7ad94246 100644 --- a/app/Jobs/DiscordTrainingUpdates.php +++ b/app/Jobs/DiscordTrainingUpdates.php @@ -80,58 +80,58 @@ public function handle() } // Function for Training Thread Availability Updates - { - // Initialize the DiscordClient inside the handle method - $discord = new DiscordClient(); + // { + // // Initialize the DiscordClient inside the handle method + // $discord = new DiscordClient(); - // Number of Messages Sent - $avail_message = 0; + // // Number of Messages Sent + // $avail_message = 0; - // Get Active Threads - $response = $discord->getClient()->get('guilds/'.env('DISCORD_GUILD_ID').'/threads/active'); - $results2 = json_decode($response->getBody(), true); + // // Get Active Threads + // $response = $discord->getClient()->get('guilds/'.env('DISCORD_GUILD_ID').'/threads/active'); + // $results2 = json_decode($response->getBody(), true); - // dd($results2); + // // dd($results2); - foreach ($results2['threads'] as $thread) { + // foreach ($results2['threads'] as $thread) { - // Get the ID of the Active Training Thread - if (preg_match('/\d+$/', $thread['name'], $matches)) { - $cid = $matches[0]; - } else { - $cid = null; - } + // // Get the ID of the Active Training Thread + // if (preg_match('/\d+$/', $thread['name'], $matches)) { + // $cid = $matches[0]; + // } else { + // $cid = null; + // } - // See if user is still a student - if($cid !== null){ - $student = Student::whereCurrent(true)->where('user_id', $cid)->first(); + // // See if user is still a student + // if($cid !== null){ + // $student = Student::whereCurrent(true)->where('user_id', $cid)->first(); - //Is the Applied Tag = "In Progress" or "Ready For Pick-Up"? - if ($student && ($thread['applied_tags'] == "1271846369510035627" || $thread['applied_tags'] == "1271847420631978107")) { + // //Is the Applied Tag = "In Progress" or "Ready For Pick-Up"? + // if ($student && ($thread['applied_tags'] == "1271846369510035627" || $thread['applied_tags'] == "1271847420631978107")) { - // Check Sessions Upcoming - $upcoming_sessions = TrainingSession::where('student_id', $student->id)->whereBetween('scheduled_time', [Carbon::now(), Carbon::now()->addDays(7)])->first(); + // // Check Sessions Upcoming + // $upcoming_sessions = TrainingSession::where('student_id', $student->id)->whereBetween('scheduled_time', [Carbon::now(), Carbon::now()->addDays(7)])->first(); - if($upcoming_sessions == null){ - // There is no sessions within the next week - $avail_message++; + // if($upcoming_sessions == null){ + // // There is no sessions within the next week + // $avail_message++; - // SendEmbed to ask student to send availability - $discord->sendEmbedInTrainingThread($cid, "Your Availability", 'Hello, <@'.$student->user->discord_user_id.'> + // // SendEmbed to ask student to send availability + // $discord->sendEmbedInTrainingThread($cid, "Your Availability", 'Hello, <@'.$student->user->discord_user_id.'> - Please provide your availability for the next 7-14 days. Please ensure to tag the `@Instructor` role with all times you are available. Please provide these times in Zulu Format. + // Please provide your availability for the next 7-14 days. Please ensure to tag the `@Instructor` role with all times you are available. Please provide these times in Zulu Format. - One of our team will make contact with you to organise a session if they have availability matching yours. + // One of our team will make contact with you to organise a session if they have availability matching yours. - *If you have done this in the past few days, please disregard this message.*'); - } - } - } - } - - // Tell the log chat - $discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'AUTO: Training Thread Availability Requests', $avail_message.' Training Threads have been messaged asking for their weekly availability. This is only completed if a student has no scheduled session within the next 7 days.'); - } + // *If you have done this in the past few days, please disregard this message.*'); + // } + // } + // } + // } + + // // Tell the log chat + // $discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'AUTO: Training Thread Availability Requests', $avail_message.' Training Threads have been messaged asking for their weekly availability. This is only completed if a student has no scheduled session within the next 7 days.'); + // } // Check 'Awaiting Exam' label students between 31-37 Days after Application {