Skip to content

Commit

Permalink
Merge pull request #339 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Further Updates
  • Loading branch information
JoshuaMicallefYBSU authored Aug 30, 2024
2 parents 59a5232 + d013d37 commit ad49783
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function schedule(Schedule $schedule)
$schedule->job(new ProcessSessionLogging())->everyMinute();

//Inactivity checks
$schedule->job(new ProcessRosterInactivity())->dailyAt('8:05');
$schedule->job(new ProcessRosterInactivity())->dailyAt('8:20');

//CRONS FOR INACTIVITY EMAILS 2 weeks
// $schedule->call(function () {
Expand Down
18 changes: 9 additions & 9 deletions app/Jobs/ProcessRosterInactivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ public function handle()
$termination_notice++;
}
}

// Send Web Notification if any changes have been made
$discord = new DiscordClient();
$discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'AUTO: Roster Inactivity Update',
'60 Days till Removed: '.$first_notice.'
30 Days till Removed: '.$second_notice.'
7 Days till Removed: '.$third_notice.'
Removed from Roster: '.$termination_notice
);
}

// Send Web Notification if any changes have been made
$discord = new DiscordClient();
$discord->sendMessageWithEmbed(env('DISCORD_WEB_LOGS'), 'AUTO: Roster Inactivity Update',
'60 Days till Removed: '.$first_notice.'
30 Days till Removed: '.$second_notice.'
7 Days till Removed: '.$third_notice.'
Removed from Roster: '.$termination_notice
);
}}
28 changes: 17 additions & 11 deletions app/Services/DiscordClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,23 @@ public function sendMessage($channelId, $message)

public function sendDM($userId, $title, $message)
{
$response = $this->client->post("https://discord.com/api/v10/users/@me/channels", [
'json' => [
'recipient_id' => $userId, // Replace $userId with the Discord user ID
],
]);

$channel = json_decode($response->getBody(), true);
$channelId = $channel['id'];

// Step 2: Send the Message to the DM Channel
$this->sendMessageWithEmbed($channelId, $title, $message);
try{

$response = $this->client->post("https://discord.com/api/v10/users/@me/channels", [
'json' => [
'recipient_id' => $userId, // Replace $userId with the Discord user ID
],
]);

$channel = json_decode($response->getBody(), true);
$channelId = $channel['id'];

// Step 2: Send the Message to the DM Channel
$this->sendMessageWithEmbed($channelId, $title, $message);

} catch (GuzzleHttp\Exception\ClientException $e) {

}
}

public function sendMessageWithEmbed($channelId, $title, $description)
Expand Down

0 comments on commit ad49783

Please sign in to comment.