Skip to content

Commit

Permalink
Merge pull request #351 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Fix Discord Update Issue
  • Loading branch information
JoshuaMicallefYBSU authored Oct 17, 2024
2 parents df74bb2 + e9f64e9 commit 7c6e009
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions app/Http/Controllers/DiscordTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Services\DiscordClient;
use Illuminate\Support\Facades\Http;
use App\Jobs\DiscordTrainingWeeklyUpdates;
use App\Jobs\ProcessShanwickController;

class DiscordTestController extends Controller
{
Expand Down Expand Up @@ -38,6 +39,20 @@ public function Job()
]);
}

public function Job2()
{
// Dispatch the job
$job = ProcessShanwickController::dispatch();

// Call the handle method directly to get the result synchronously
$result = $job->handle();

return response()->json([
'message' => 'Job executed successfully',
'data' => $result,
]);
}

public function SendEmbed()
{
//New Applicant in Instructor Channel
Expand Down
5 changes: 3 additions & 2 deletions app/Jobs/DiscordTrainingWeeklyUpdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,12 @@ public function handle()

// Terminate Training
{
$term_training++;
$terminate_names["names"][] = $thread['name'];
$s = Student::where('created_at', '<=', Carbon::now()->subDays(60))->where('user_id', $cid)->first();

if($s != null && $s->hasLabel('Awaiting Exam')){
$term_training++;
$terminate_names["names"][] = $thread['name'];

//Make as not current
$s->current = false;

Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
// Discord shortcut
Route::get('/discord', [DiscordController::class, 'joinShortcut']);
Route::get('/discord/function-test', [DiscordTestController::class, 'Job']);
Route::get('/discord/function-test2', [DiscordTestController::class, 'Job2']);
Route::post('/discord/bot-webhook', [DiscordController::class, 'handelDiscordCommand']);

// Public news articles
Expand Down

0 comments on commit 7c6e009

Please sign in to comment.