Skip to content

Commit

Permalink
Merge pull request #364 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Final Fix
  • Loading branch information
JoshuaMicallefYBSU authored Oct 20, 2024
2 parents 0e0f52e + c20bad6 commit 9a092ec
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/DiscordTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
28 changes: 20 additions & 8 deletions app/Jobs/DiscordAccountCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
);

}

Expand All @@ -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,
);
}

}

Expand All @@ -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.',
);
}


Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down

0 comments on commit 9a092ec

Please sign in to comment.