diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ffc2b3a9..e6e1770c 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -43,7 +43,7 @@ protected function schedule(Schedule $schedule) $schedule->job(new ProcessSessionLogging())->everyMinute(); //Inactivity checks - $schedule->job(new DiscordAccountCheck())->dailyAt('10:52'); + $schedule->job(new DiscordAccountCheck())->dailyAt('11:25'); //Inactivity checks $schedule->job(new ProcessRosterInactivity())->daily(); diff --git a/app/Http/Controllers/DiscordTestController.php b/app/Http/Controllers/DiscordTestController.php index 80ef500f..22413047 100644 --- a/app/Http/Controllers/DiscordTestController.php +++ b/app/Http/Controllers/DiscordTestController.php @@ -58,20 +58,20 @@ public function SendEmbed() //New Applicant in Instructor Channel $discord = new DiscordClient(); - $discord->sendMessageWithEmbed('1274827382250934365', 'Discord Account Not Linked on CZQO', + $discord->sendMessageWithEmbed('488265136696459292', 'Discord Account Not Linked on CZQO', 'Dear Gander Members, -If you have been pinged in this message, it means your discord account is not linked with our Gander Oceanic Website. +If you have been pinged in this message, it means your discord account is not linked on the Gander Oceanic Website. -We ask that you head to the [Gander Oceanic Website](https://ganderoceanic.ca/my) to link your Discord Account. Your roles will be assigned at 0400z each day. +We ask that you head to the [Gander Oceanic Website](https://ganderoceanic.ca/my) to link your Discord Account. This will automatically update your roles and name with Gander Oceanic daily. Access for users not linked will be limited from the 11/31/2024. Thank You, Gander Oceanic Team -<@&1278606316906090527>'); +<@&1297422968472997908>'); } public function DiscordRoles() diff --git a/app/Jobs/DiscordAccountCheck.php b/app/Jobs/DiscordAccountCheck.php index f801f0d7..7abb82ce 100644 --- a/app/Jobs/DiscordAccountCheck.php +++ b/app/Jobs/DiscordAccountCheck.php @@ -74,12 +74,10 @@ public function handle() sleep(2); // Check if user is currently in Discord - foreach($discord_uids as $discord_uid){ - - - if($user->discord_user_id == $discord_uid){ + if (in_array($user->discord_user_id, $discord_uids)) { ## User is in the Discord - + $discord_uid = $user->discord_user_id; + // Get Discord Member Information $discord_member = $discord->getClient()->get('guilds/'.env('DISCORD_GUILD_ID').'/members/'.$discord_uid); $discord_member = json_decode($discord_member->getBody(), true); @@ -163,7 +161,11 @@ public function handle() } } - // dd($rolesToAdd); + $discord->sendMessageWithEmbed( + '1297517512904409099', + 'IN DISCORD: '.$user->fullName('FLC'), + 'User is in the Discord. '.$user->member_of_czqo, + ); } @@ -183,9 +185,13 @@ public function handle() // Update DB Information $user->member_of_czqo = false; $user->save(); - } - } + $discord->sendMessageWithEmbed( + '1297517512904409099', + 'NOT IN DISCORD '.$user->fullName('FLC'), + 'User is NOT in the Discord. '.$user->member_of_czqo, + ); + } } @@ -197,6 +203,12 @@ public function handle() // add role $discord->getClient()->put('guilds/'.env('DISCORD_GUILD_ID').'/members/'.$discord_uid.'/roles/1297422968472997908'); + + $discord->sendMessageWithEmbed( + '1297517512904409099', + 'NOT LINKED: '.$user->fullName('FLC'), + 'User is not linked with CZQO.', + ); } diff --git a/routes/web.php b/routes/web.php index 98efbfc1..3c25efcb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -75,7 +75,7 @@ // Discord shortcut Route::get('/discord', [DiscordController::class, 'joinShortcut']); -Route::get('/discord/function-test', [DiscordTestController::class, 'Job']); +Route::get('/discord/function-test', [DiscordTestController::class, 'SendEmbed']); // Route::get('/discord/function-test2', [DiscordTestController::class, 'Job2']); Route::post('/discord/bot-webhook', [DiscordController::class, 'handelDiscordCommand']);