Active Effect Help

Bbadideasbureau9/14/2021
And it should be the actual ActiveEffect document for the effect, not just the id. I don't have the brain right now to figure out the best way to get that.
Eethck9/14/2021
I really thought I could figure it out, but the updates just aren't going through.

Here is the current state of the macro:
console.log(args);
if(args[0] === "each"){
  let effect = args[2].efData.document; //the active effect which adds the AC bonus
  //the Item for Armor of Agathys, set up as innate spellcasting with 0/1 uses.
  let armorOfAgathys = game.items.getName("Armor of Agathys");
  let bonus = parseInt(effect.data.changes[1].value);
  if(bonus < 6){
    console.log(effect.data.changes[1].value, effect);
    effect.update({"data.changes[1].value": bonus+3});
  } else {
    armorOfAgathys.update({"data.uses.value": 1});
  }
}

Some stuff still needs to be adjusted.
Eethck9/14/2021
DAE list:
Eethck9/14/2021
(I don't think it pings on thread creation??? So just throwing out a ping. Sorry if it actually did! @BadIdeasBureau
Aarcanist9/14/2021
Maybe you need to await the updates?
Eethck9/14/2021
I thought that as well but tried it and no dice :(
Eethck9/14/2021
The problem (as far as I understand it) is that the effect.update is not going through. I've double checked the keyname and it is a valid name. I also just tried a really simple key name, but the data wasn't modified either, so I think there's something else going on but I have no idea what.
Eethck9/14/2021
If anything I'm thinking it might be that I have the wrong effect selected? But that really should be the right one...
Bbadideasbureau9/14/2021
Honestly not sure - try throwing in a console.log(effect) to check it's the right one?
Eethck9/14/2021
I did. Here's the output (afaik it's the right one???).
Bbadideasbureau9/14/2021
OH! effect.update({"changes[1].value": (the "update" applies to "data", so you skip the first "data")

I think you still want the "data" in armor of agathys, since that's system defined data (so it's actually item.data.data.uses.value)
Eethck9/14/2021
That would make sense, but it still doesn't work.
Eethck9/14/2021
Are you allowed to use array indexing in the key field?
Eethck9/14/2021
Okay, it's definitely because of that
Eethck9/14/2021
If I change the key to "label" then it immediately works
Eethck9/14/2021
I'm going to throw a general question over into #development