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
When you say 'my' custom messages, are you in the context of a system?
module
just some interactivity that requires more than static html
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
I see
Before I close this, how would you create a fakeuser for the purpose of changing a chat message's avatar and name?
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 thosethat makes sense
thanks for the help