Overriding the ChatMessage class?

I've been using the "renderChatMessage" hook to render my custom chat messages, but from what I can tell, Foundry is moving to more declarative overrides with classes. Having complete control over the rendering of my chat message would be very helpful. I imagine you'd have to override the type field that the document can support, as well as its render function, but I don't know how exactly to go about it. Using typescript, btw.
6 Replies
esheyw
esheyw4mo ago
When you say 'my' custom messages, are you in the context of a system?
0x4434
0x4434OP4mo ago
module just some interactivity that requires more than static html
esheyw
esheyw4mo ago
For a module sticking with the render hook is still the way to go. If you only care about specific systems, and those systems suppose module subtypes for chatmessages, then you could look into doing that, but replacing the outer Document classes is generally a thing only systems do
0x4434
0x4434OP4mo ago
I see Before I close this, how would you create a fakeuser for the purpose of changing a chat message's avatar and name?
esheyw
esheyw4mo ago
tbh I don't mess with messages much, but i believe there's an alias you can pass in ChatMessage.getSpeaker and then you pass that into message creation? any avatar in the chat message is going to be system-specific, core chat cards don't have those
0x4434
0x4434OP4mo ago
that makes sense thanks for the help

Did you find this page helpful?