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 .
×
Advertisement Create a free account

API: Please fix chat:message.who

1589548618

Edited 1589548690
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
So this has been an annoyance for a while now for myself and my scripts' users. Sometimes when I try to whisper a message to a player using the "who" property of a message object, it doesn't work and gives them a console log error like this: {"who":"error","type":"error","content":"Unable to find a player or character with name: L337HaxX0rGM"} This is usually because they've set their in-game name to something that is not their canonical Roll20 username, but not always. Other times it has been because they might have special characters in their names. Other times it has done this for reasons I could not diagnose while trying to help these users. In my scripts, I've been able to use a work-around suggested by Aaron a long time ago that works something like this: /** * @private * Whispers a Marching Order message to someone. */ function _whisper(who, msg) { sendChat('Its A Trap! script', '/w "' + _fixWho(who) + '" ' + msg); } /** * Fixes msg.who. * @param {string} who * @return {string} */ function _fixWho(who) { return who.replace(/\(GM\)/, '').trim(); } The "who" argument in the above functions is expected to come from the chat:message  object's "who" property. Sadly this workaround doesn't always work.  Please fix message.who so that it can be used to whisper back to the user.
Hi Stephen, I’ve tried private messaging you about a different question. But it’s not working. Do you know why that might be?  I get the message “Not authorised to post”
1592838975
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Jack M. said: Hi Stephen, I’ve tried private messaging you about a different question. But it’s not working. Do you know why that might be?  I get the message “Not authorised to post” I have never seen that message before, so I have no idea.
Oh! It just worked. I think the problem was either the browser or the crap tablet i was on!