Restrict skill usage when an enemy in battle has a certain state

I have been using YEP Skill Core plugin to restrict my actors from casting spells in some certain condition. Now i have a skill which applies a state to an actor, or an enemy. I want to restrict my actor from casting this skill when any member in battle (including actors and enemies) is still affected by this state. So far, i have been successfully doing this on my party by checking the number of actors affected by the state via this condition:
Code:
<Custom Requirement>
if ($gameParty.battleMembers().filter( function (actor) { return actor.isStateAffected(67); } ).length > 0){
value = false;
}
else{
value = true;
}
</Custom Requirement>

However, i haven't figured out a way to do so when the state affects an enemy. So i want to know how to apply the above condition to $gameTroop and check the number of enemies affected.
Have you tried replacing $gameParty with $gameTroop?
I haven't tried, because i'm not sure about the rest of the code. Can i use this:
Code:
$gameTroop.aliveMembers().filter( function (enemy) { return enemy.isStateAffected(67); } ).length > 0

EDIT: It did work! Thank you for your help @SwiftSign 😀

Original thread: https://forums.rpgmakerweb.com/threads/restrict-skill-usage-when-an-enemy-in-battle-has-a-certain-state.99253/