Skip to content

Commit

Permalink
Merge pull request #373 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Update DiscordAccountCheck.php
  • Loading branch information
JoshuaMicallefYBSU authored Oct 20, 2024
2 parents a8d701b + c8f0ef9 commit 66aa389
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions app/Jobs/DiscordAccountCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function handle()
// Initialise some variables
$checked_users = 0;
$accounts_not_linked = 0;
$in_discord = 0;
$not_in_discord = 0;
$discord_uids = [];

Expand All @@ -50,14 +51,11 @@ public function handle()
$response = $discord->getClient()->get('guilds/'.env('DISCORD_GUILD_ID').'/members?limit=1000');
$discord_members = json_decode($response->getBody(), true);

// dd($discord_members);

// Loop through each Discord User and get some key information
foreach($discord_members as $members){
$discord_uids[] = $members['user']['id'];
// dd($members['user']);
}
// dd($discord_uids);

// Get a complete list of Gander Oceanic Users
$users = User::whereNotNull('discord_user_id')->get();
Expand All @@ -77,8 +75,10 @@ public function handle()

// Check if user is currently in Discord
if (in_array($user->discord_user_id, $discord_uids)) {

## User is in the Discord
$discord_uid = $user->discord_user_id;
$in_discord++;

// Get Discord Member Information
$discord_member = $discord->getClient()->get('guilds/'.env('DISCORD_GUILD_ID').'/members/'.$discord_uid);
Expand Down Expand Up @@ -172,13 +172,6 @@ public function handle()
$rolesToAdd[] = $roleId; // Add the role ID to rolesToAdd if present in user's roles
}
}

$discord->sendMessageWithEmbed(
'1297517512904409099',
'IN DISCORD - '.$user->fullName('FLC'),
'User is in the Discord. '.$user->member_of_czqo,
);

}


Expand Down Expand Up @@ -209,12 +202,6 @@ public function handle()

// add role
$discord->getClient()->put('guilds/'.env('DISCORD_GUILD_ID').'/members/'.$discord_uid.'/roles/1297422968472997908');

$discord->sendMessageWithEmbed(
'1297517512904409099',
'NOT LINKED - '.$discord_uid,
'Discord User is not connected with Gander Oceanic.',
);
}


Expand All @@ -227,7 +214,8 @@ public function handle()
$update_content .= "\n\n **__Accounts:__**";

// Users which are linked in Discord
$update_content .= "\n- Accounts Linked: ".$checked_users." (name/roles updated)";
$update_content .= "\n- Total Accounts: ".$checked_users." (name/roles updated)";
$update_content .= "\n- Linked & In Discord: ".$in_discord;
$update_content .= "\n- Linked but not in Discord: ".$not_in_discord;

// Accounts not linked
Expand Down

0 comments on commit 66aa389

Please sign in to comment.