mclemente / fvtt-condition-lab-triggler

Condition Lab & Triggler module for Foundry Virtual Tabletop
GNU General Public License v3.0
6 stars 4 forks source link

Output to Chat not working when actor has no current chat entries. #32

Closed grimsdalee closed 7 months ago

grimsdalee commented 7 months ago

Describe the bug When applying a condition with Out to Chat option enabled, and that actor has no current chat entries (new actor or if chat has been cleared), it does not generate the chat entry & error is generated. If the actor has a chat entry, then this works as expected.

To Reproduce Steps to reproduce the behavior:

  1. Make sure Output to Chat option is enabled in the Module settings.
  2. Create a condition and set its option to Output to Chat.
  3. Create a token from an actor.
  4. Clear the chat log.
  5. Apply the condittion on the token.
  6. No Chat for the condition is created & shows following error:

condition-lab-triggler.js:620 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'timestamp') at EnhancedConditions.outputChatMessage (condition-lab-triggler.js:620:54) at EnhancedConditions._processActiveEffectChange (condition-lab-triggler.js:499:40) at EnhancedConditions._onDeleteActiveEffect (condition-lab-triggler.js:355:22) at Object.fn (condition-lab-triggler.js:4491:21) at #call (foundry.js:730:20) at Hooks.callAll (foundry.js:687:17) at ClientDatabaseBackend.callback (foundry.js:13837:13) at foundry.js:13812:43 at Array.map () at #handleDeleteDocuments (foundry.js:13812:33) at async ActiveEffect.deleteDocuments (commons.js:8046:23) at async EnhancedConditions.removeCondition (condition-lab-triggler.js:1687:4) at async Triggler._executeTrigger (condition-lab-triggler.js:1980:4) at async Triggler._processUpdate (condition-lab-triggler.js:2192:5)

Expected behavior Chat log to be generated for the applied condition.

Screenshots image image image image

Environment Info (please complete the following information):

Additional context If you generate a chat entry for that token/actor (like a dice roll or comment), then this function works correctly and generates the expected chat update: image