Is there a command that detects if a player has an effect?
Solution 1:
Why Doesn’t it Work
Minecraft Java ActiveEffects tag is written as a byte, and values over 127 will wrap around to -127. This means that level 128 is actually -127. 255 is actually -1.
Solution
Try this:
/execute if entity @a[nbt={ActiveEffects:[{Id:5b, Amplifier: -1b}]}]