Skip to content

[BUG] dnd5e.renderChatMessage is skipped for usage messages in 5.3.x #6852

Description

@Kapuzenjoe

I know 5.3.0 is not officially released yet, but I wanted to report this early because it looks like a small regression in the chat message render flow.

The Hook dnd5e.renderChatMessage does not seem to fire for the new usage-messages when they are re-rendered after message.setFlag(...).

I can reproduce it with a normal dnd5e usage message and a simple macro. renderChatMessageHTML still fires, so the message does re-render, but the dnd5e-specific post-render hook appears to be skipped. This same general workflow worked for me in 5.2.x.

Steps to Reproduce

  1. Create any normal dnd5e usage-message, for example by using an item/activity that creates a usage message.
  2. Make sure that usage-message is the latest chat message.
  3. Run this macro:
Hooks.on("renderChatMessageHTML", (message) => {
  console.log("renderChatMessageHTML", message.id, message.type);
});

Hooks.on("dnd5e.renderChatMessage", (message) => {
  console.log("dnd5e.renderChatMessage", message.id, message.type);
});

const message = game.messages.contents.at(-1);
await message?.setFlag("world", "testFlag", foundry.utils.randomID());
  1. Check the console output.

For me, renderChatMessageHTML fires for the updated message, but dnd5e.renderChatMessage does not.
If I repeat the same test with a regular base chat message, both hooks fire as expected

This looks related to the early return in chat-message.mjs:

if ( foundry.utils.getType(this.system?.getHTML) === "function" ) {
  await this.system.getHTML(html, options);
  return html;
}

That seems to skip the later Hooks.callAll("dnd5e.renderChatMessage", this, html) for messages rendered through system.getHTML.

Tested without any modules on Foundry V13 351 and V14 358, using the latest current 5.3.x branch state from GitHub.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions