diff --git a/app/Http/Controllers/DiscordTestController.php b/app/Http/Controllers/DiscordTestController.php index 7d47ead8..de9f5a2c 100644 --- a/app/Http/Controllers/DiscordTestController.php +++ b/app/Http/Controllers/DiscordTestController.php @@ -4,7 +4,7 @@ use Illuminate\Http\Request; use App\Services\DiscordClient; -use App\Jobs\UpdateDiscordUserRoles; +use App\Jobs\DiscordAccountCheck; class DiscordTestController extends Controller { @@ -26,7 +26,7 @@ public function EditTagTest() public function Job() { // Dispatch the job - $job = UpdateDiscordUserRoles::dispatch(); + $job = DiscordAccountCheck::dispatch(); // Call the handle method directly to get the result synchronously $result = $job->handle(); diff --git a/app/Jobs/DiscordAccountCheck.php b/app/Jobs/DiscordAccountCheck.php new file mode 100644 index 00000000..2e47163d --- /dev/null +++ b/app/Jobs/DiscordAccountCheck.php @@ -0,0 +1,74 @@ +getClient()->get('guilds/'.env('DISCORD_GUILD_ID').'/members?limit=1000'); + // $response = $discord->getClient()->get('guilds/'.env('DISCORD_GUILD_ID').'/members'); + $discord_members = json_decode($response->getBody(), true); + // $discord_members[0]['nick'] = "Joshua Micallef 1342084"; + // dd($discord_members); + + // Get All Users where member_of_czqo = 0 & used_connect = 1 + $users_not_linked = User::where('member_of_czqo', 0)->where('used_connect', 1)->get()->toArray(); + // dd($users_not_linked); + + // foreach ($threads_data['threads'] as $thread) { + // if (strpos($thread['name'], $cid) !== false) { + + // Go through each Discord Member + foreach($discord_members as $discord_user){ + + foreach($users_not_linked as $users){ + + // dd($users); + + // Variables to be compared + $name = $discord_user['nick']; + $cid = $users['id']; + + // CID matches ID of user not linked + if (strpos($name, $cid) !== false) { + $discord = new DiscordClient(); + + $discord->assignRole($discord_user['user']['id'], '1278606316906090527'); + } + + } + } + } + +}