Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×

SendChat misattributing messages in chat archive

1770058183

Edited 1770058505
Quinn
Pro
Sheet Author
The issue I'm trying to solve is this: Say something as character A Say something as character A Say something as character B Result:  Looks great! now, let's add a very simple API command: on('chat:message', function(msg) { if(msg.type == 'api' && msg.content.indexOf('!attack') == 0) { sendChat(msg.who, "Comment."); } }); Then: Say something as character A !attack as character A !attack as character B Result: Cacta's icon doesn't appear, and the system generally doesn't seem to acknowledge that as being a message sent by Cacta. Even worse, in the chat archive, it looks like this: Not even Cacta's name shows up! It just looks like three messages by Quinn. Looking at logged msg objects, I notice that they have a "rolledByCharacterId" property, which I think is what isn't being set by SendChat. Is there a workaround for this, so that API messages aren't getting incorrectly attributed to the wrong person? It even happens if different players do the commands, which can make the chat very confusing, both during play and in the archive.
1770064047
Quinn
Pro
Sheet Author
I've actually been grappling with this bug for close to a decade. This is the first time I've successfully reproduced it in such a simple form.
1770077778

Edited 1770077892
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It's because it's not supposed to use the avatar or connect it to other messages that were sent when you only pass a name. If you want to reference that specific player, you have to use the player's id when you use sendChat. See the wiki for more information . EDIT: Note that it won't ever appear as a message "you" sent (e.g. with the blue background) regardless of what information you give it, at least as far as I'm aware.
1770078564
Quinn
Pro
Sheet Author
YES! Using "character|-123abc" as the speakingAs works! After ten thousand years, I'm free! Thanks for the tip!