MZ Add a buff to all party members

What's the script call to do that? Thanks!
Don't know if this is the most efficient way, but it works for me.

JavaScript:
let targets = $gameParty.aliveMembers();
targets.forEach(function(target) {
    target.addBuff(X, Y);
});

Replace X with the Parameter ID
->
0 - Max HP
1 - Max MP
2 - Attack
3 - Defence
4 - Magic Attack
5 - Magic Defence
6 - Agility
7 - Luck

Replace Y with the amount of turns the buff persists

EDIT: This solution is for MV, but it should work for MZ aswell, atleast supposedly.

Original thread: https://forums.rpgmakerweb.com/threads/add-a-buff-to-all-party-members.136641/