Active-Auras
Active-Auras copied to clipboard
Adding a placeholder token in the combat tracker can lead to TypeError Undefined when reading document in AAHooks.mjs:51
AAHooks.mjs:51
If you have placed in the Combat tracker a Placeholder token, this can fail
export async function updateCombatHook(combat, changed, options, userId) {
if (canvas.scene === null) {
Logger.debug("Active Auras disabled due to no canvas");
return;
}
if (changed.round === 1) {
ActiveAuras.MainAura(undefined, "combat start", canvas.id);
return;
}
if (!("turn" in changed)) return;
let combatant = canvas.tokens.get(combat.current.tokenId);
let previousCombatant = canvas.tokens.get(combat.previous.tokenId);
- await previousCombatant.document.update({ "flags.ActiveAuras": false });
+ await previousCombatant?.document.update({ "flags.ActiveAuras": false });
Logger.debug("updateCombat, main aura");
- await ActiveAuras.MainAura(combatant.document, "combat update", combatant.scene.id);
+ if (combatant) await ActiveAuras.MainAura(combatant.document, "combat update", combatant.scene.id);
}
I guess both previous and current combatants should be able to bail out in that case, but I havent traced the error stack more to see if it might fail elsewhere.
@yenbengreyarm caught this :thumbsup:
(moved here from posney's discord)