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

API sendChat format to a rolltemplate?

Is it possible to use sendChat function to send a message that formats to a rolltemplate? I have been trying to with only partial success. Messages that I send in chat that format correctly, fail when I attempt to do it as a sendchat from the API. Any ideas?
1431898353
The Aaron
Pro
API Scripter
Can you post your code? I've not had problems getting this to work.
1431898442
The Aaron
Pro
API Scripter
Here's a hack of BlindRoll that supports whispering roll templates: on("chat:message", function(msg_orig) { "use strict"; var msg = _.clone(msg_orig), who; if (msg.type !== "api") { return; } if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ m['$[['+k+']]']=v.results.total || 0; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },msg.content) .value(); } who=getObj('player',msg.playerid).get('_displayname').split(' ')[0]; var cmdName = "!broll "; var msgTxt = msg.content; var msgWho = msg.who; var msgFormula = msgTxt.slice(cmdName.length); if(msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) { if(_.has(msg,'rolltemplate')) { sendChat(msgWho,'/w gm &{template:'+msg.rolltemplate+'}'+msg.content); sendChat(msgWho, "/w " + who + " secret rolltemplate sent to GM"); } else { sendChat(msgWho, "/gmroll " + msgFormula); sendChat(msgWho, "/w " + who + " secret roll sent to GM (" + msgFormula + ")"); } }; });
This is what is not working, I think it has a problem with the "{{roll=[[ 1d20 ]]}}" var finalMessage = "&{template:5eDefault} {{character_name=this is a name}}} {{save=1}} {{title=Title}} {{subheader=This is a subheader name}}} {{rollname=Rollname}} {{roll=[[ 1d20 ]]}}"; sendChat(msg.who, finalMessage);
1431898961
The Aaron
Pro
API Scripter
So, it appears that the API doesn't like the spaces around the 1d20. This worked for me: on('ready',function(){ var finalMessage = "&{template:5eDefault} {{character_name=this is a name}}} {{save=1}} {{title=Title}} {{subheader=This is a subheader name}}} {{rollname=Rollname}} {{roll= [[1d20]] }}"; sendChat('Who', finalMessage); })
Wow! Thanks!
1431900192
The Aaron
Pro
API Scripter
No worries! I'll raise that as a bug. =D