Skip to content

Commit

Permalink
Merge pull request #380 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Update DiscordAccountCheck.php
  • Loading branch information
JoshuaMicallefYBSU authored Oct 22, 2024
2 parents 9be2163 + 225acd9 commit c61a940
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions app/Jobs/DiscordAccountCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function handle()
}
}

$rolesToAdd = array_diff($rolesToAdd, $discord_member['roles']);
$discord_roles = array_unique($rolesToAdd);
}

// Name Format for ZQO Members and Other Members
Expand All @@ -234,24 +234,15 @@ public function handle()
$name = $user->FullName('FLC');
}

// Check if the roles are different between Discord and the DB
$diff1 = array_diff($discord_member['roles'], $rolesToAdd);
$diff2 = array_diff($rolesToAdd, $discord_member['roles']);

// Update user
$discord->getClient()->patch('guilds/'.env('DISCORD_GUILD_ID').'/members/'.$user->discord_user_id, [
'json' => [
'nick' => $name,
'roles' => $discord_roles,
]
]);

// Name is same on Discord, as well as roles
if ($name == $discord_member['nick'] && (!empty($diff1) || !empty($diff2))) {
// Update user
$discord->getClient()->patch('guilds/'.env('DISCORD_GUILD_ID').'/members/'.$user->discord_user_id, [
'json' => [
'nick' => $name,
'roles' => $rolesToAdd,
]
]);

// Sleep API Check
sleep(2);

}

} else {
## User is NOT in the discord
Expand Down

0 comments on commit c61a940

Please sign in to comment.