Blind Chat Messages
Anyone have good examples of creating a chat message that should only be visible to a connected GM, but might be created by any connected client?
7 Replies
What I've got:
however, the created chat message is visible plain as day to the creator
It looks to me like
ChatMessage.isVisible
makes a chat message visible to the creating user always (comments mine):
Trying to feed the api the GM's user id as speaker
makes an error that the user lacks permissionLooks like this isn't strictly possible...
https://gitlab.com/foundrynet/foundryvtt/-/issues/4317
GitLab
Suggestion: Private GM / Blind / Self Roll should also apply to cha...
Currently, if you just type some text into the chat box (i.e. not a roll), it does not honour the current default roll setting (public, private, blind, self)....
workaround time
You need to hook into renderChatMessage and do html.remove() for non-GMs or something.
Or possibly just hide them, in case Foundry gets huffy about the DOM element being missing.
If I put a flag to help distinguish which cards are mine, I can catch them in a renderChatMessage hook and nuke them yeah.
Hiding them is probably a better play
which would be easiest if I can set a class on the overall chat message instead of just its contents
cssClass
on messageData?
noope
:has
would solve me... https://caniuse.com/css-hasrenderChatMessage happens before the chat message is actually visible, so as long as you aren't turning the hook async, you can modify it all you like before it gets shown.
Yeah I ended up adding a class to the html in the hook if the message has my flag.
It's annoying to me that I need to make code which runs on every message to affect only mine though.
I gave my thumbsup to the issue I linked.
@drl2 you might find this thread insightful