diff --git a/src/Discord/Repository/Guild/RoleRepository.php b/src/Discord/Repository/Guild/RoleRepository.php index 9598c17c7..3ced3a7e6 100755 --- a/src/Discord/Repository/Guild/RoleRepository.php +++ b/src/Discord/Repository/Guild/RoleRepository.php @@ -77,9 +77,13 @@ public function getCurrentMemberHighestRole(): ?Role return null; } - return $guild->roles + /** @var array */ + $role = $guild->roles ->filter(fn (Role $role) => $botMember->roles->has($role->id)) ->sort(fn (Role $a, Role $b) => $b->comparePosition($a)) - ->shift(); + ->shift() ?? []; + + /** @var Role|null */ + return array_shift($role); } }