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 .
×

[Help] New to APi, and the msg object / inlinerolls is driving me batty

I'm trying to just pass a msg object with an inline roll to an array, and then pull the result.  I've spent 2 days on this now, and all the examples I see don't seem to help. Here's my code: on("chat:message", function(msg)   {   if(msg.type == "api" && msg.content.indexOf("!DR") !== -1)      {        var Msgcontent = new Array();        sendChat(" ", "[[1d10]]", function (roll) {          var msgContent = roll;          log (msgContent.inlinerolls);        });       } }) When I log just MsgContent, I see the general msg object with inline rolls information, but when I try to actually access the information, it keeps coming back as undefined.   I'm sure it's something stupid, but I've maxed my ability to troubleshoot. 
1587347067
The Aaron
Roll20 Production Team
API Scripter
Ah, this tripped me up sooooo much when I first started.  The argument passed to the callback from sendChat() is an array: on("chat:message", (msg) => { if(msg.type == "api" && msg.content.indexOf("!DR") !== -1) { var Msgcontent = []; sendChat(" ", "[[1d10]]", (roll) => { var msgContent = roll[0]; log (msgContent.inlinerolls); }); } }); That's because you could send it something like: on("chat:message", (msg) => { if(msg.type == "api" && msg.content.indexOf("!DR") !== -1) { var Msgcontent = []; sendChat("", "[[1d10]]\n[[1d2]]\n[[2d3]]", (rolls) => { rolls.forEach(r=>log(r.inlinerolls)); }); } }); Hope that helps!
It does!  Thanks - that saved me days of pulling my hair out.
1587350994
The Aaron
Roll20 Production Team
API Scripter
Great!  Don't wait days if you run into problems with the API, jump on and ask, we're happy to help!
You know how it goes.  Sometimes breaking something consistently helps you understand it better.  :)
1587405306
The Aaron
Roll20 Production Team
API Scripter
I totally agree, hence why everything I have in development is constantly broken! =D  There are definitely some eccentricities to the API that will drive you batty though, so if something doesn't seem to make sense, it's probably broken. =D