From 78dd2179da1b76aa742efa4abc62a1a484eda973 Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Fri, 16 Aug 2024 02:34:23 +1000 Subject: [PATCH] Fix Remove Button Issue --- .../Training/InstructingController.php | 4 +++- app/Services/DiscordClient.php | 18 +++++++++--------- .../instructing/students/student.blade.php | 4 ++-- routes/web.php | 1 - 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Training/InstructingController.php b/app/Http/Controllers/Training/InstructingController.php index 256f7353..00fbe435 100644 --- a/app/Http/Controllers/Training/InstructingController.php +++ b/app/Http/Controllers/Training/InstructingController.php @@ -401,13 +401,15 @@ public function removeStudent($cid) $student->user->removeRole('Student'); //Discord Updates - if ($student->user->hasDiscord() && $student->user->member_of_czqo) { + if (!$student->user->hasDiscord()) { //Get Discord client $discord = new DiscordClient(); //remove student discord role $discord->removeRole($student->user->discord_user_id, 482824058141016075); + $discord->EditThreadTag('Inactive', $student->user->fullName('FLC')); + //close Instructor Thread $discord->closeTrainingThread($student->user->fullName('FLC'), 'cancel'); diff --git a/app/Services/DiscordClient.php b/app/Services/DiscordClient.php index e0670328..73c3a7c4 100644 --- a/app/Services/DiscordClient.php +++ b/app/Services/DiscordClient.php @@ -127,6 +127,14 @@ public function closeTrainingThread($name, $status) foreach ($threads_data['threads'] as $thread) { if ($thread['name'] == $name) { + // Lock and Archive the Thread + $data = $this->client->patch('channels/'.$thread['id'], [ + 'json' => [ + 'locked' => true, + 'archived' => true, + ] + ]); + if($status == "certify"){ $this->sendMessageWithEmbed($thread['id'], 'Oceanic Training Completed!', 'Congratulations, you have now been certified on Gander & Shanwick Oceanic! @@ -137,19 +145,11 @@ public function closeTrainingThread($name, $status) Enjoy controlling Gander & Shanwick OCA!'); } elseif($status == "cancel") { - $this->sendMessageWithEmbed($thread['id'], 'Oceanic Training Cancelled!', + $this->sendMessageWithEmbed($thread['id'], 'Oceanic Training Cancelled', 'Your training request with Gander Oceanic has been terminated. If you would like to begin training again, please re-apply via the Gander Website.'); } - - // Lock and Archive the Thread - $data = $this->client->patch('channels/'.$thread['id'], [ - 'json' => [ - 'locked' => true, - 'archived' => true, - ] - ]); } } diff --git a/resources/views/admin/training/instructing/students/student.blade.php b/resources/views/admin/training/instructing/students/student.blade.php index 304b438b..82d2cfcb 100644 --- a/resources/views/admin/training/instructing/students/student.blade.php +++ b/resources/views/admin/training/instructing/students/student.blade.php @@ -56,11 +56,11 @@