From 2b318076c3889db2ffe2a0e241a0b206d6232120 Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:51:17 +1000 Subject: [PATCH] Update DiscordAccountCheck.php --- app/Jobs/DiscordAccountCheck.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Jobs/DiscordAccountCheck.php b/app/Jobs/DiscordAccountCheck.php index 89e65c53..6432b664 100644 --- a/app/Jobs/DiscordAccountCheck.php +++ b/app/Jobs/DiscordAccountCheck.php @@ -259,6 +259,10 @@ public function handle() $rolesToRemove = array_diff($discord_member['roles'], $combinedRoles); if (!empty($rolesToAssign) || !empty($rolesToRemove) || $name !== $discord_member['nick']) { + + // Sleep for 1 second (let API catch up) + sleep(1); + $message = "Assign Roles:"; foreach($rolesToAssign as $role){ $message .= "\n- $role"; @@ -281,6 +285,8 @@ public function handle() ]); foreach ($staffRoles as $role){ + + // Slow down multi role add. Allow API to catch up sleep(0.75); // add role @@ -316,7 +322,7 @@ public function handle() $accounts_not_linked++; //records that Account Not Linked Role Assigned - sleep(0.75); + sleep(1); // // Update user with main roles - Will temp remove staff roles $discord->getClient()->patch('guilds/'.env('DISCORD_GUILD_ID').'/members/'.$user->discord_user_id, [