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 giving weird error and it did not do this the other day

Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: TypeError: Cannot read property 'split' of undefined TypeError: Cannot read property 'split' of undefined at apiscript.js:42113:58 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1648:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Zd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:400 Getting this error when using this menu macro: /w gm &{template:default} {{name=Configurator}} {{ [Group Initative](!group-init --help) [Dead Status Tracker](!dead config) [Status Info Tracker](!condition config) [Concentration Tracker](!concentration config) [Group Check](!group-check-config) [Audio Master](!roll20AM --config) [Roll Listener](!crl \\config) [XP Tracker](!xp config) [Treasure](!treasure config) [AoE Menu](!areasOfEffectShowMenu) [Heartbeat](!api-heartbeat) [Observer](!observer  --help) [Loot Tables](!loot config) [Purse Strings](!ps --help) }}
1585690064
The Aaron
Roll20 Production Team
API Scripter
What API scripts do you have installed?
API Scripts for BP Ashland Use caution when utilizing the API. We recommend making regular copies of your Game, as the API can delete your data if misused. Script Library G ChatSetAttr G EasyExperience G GroupInitiative G namegen G Customizable Roll Listener G GroupCheck G Vector Math G MatrixMath G Path Math G One-Way Dynamic Lighting G Roll20 Audio Master G InspirationTracker G Token Collisions G HTML Builder G It's a Trap! G It's a Trap! - D&D 5E Generic G Areas of Effect G Marching Order G TokenMod G Resizer G PowerCards G splitArgs G Observer Combat Master G libTokenMarkers G Torch G Token Fate TurnMarker Blood and Honor G Door Knocker G DLEllipseDrawer Av3 Marching Order G 5th Edition OGL by Roll20 Companion New Script
1585691674
The Aaron
Roll20 Production Team
API Scripter
hmm.  One of those has a problem...  it will be a script with a chat event handler that isn't checking the message type.  Probably easiest to disable half the scripts, try your command, see if it crashes, then either flip the disabled and enabled to get the crash, or subdivide the active set until you get to one script that causes the crash.
The Aaron said: hmm.  One of those has a problem...  it will be a script with a chat event handler that isn't checking the message type.  Probably easiest to disable half the scripts, try your command, see if it crashes, then either flip the disabled and enabled to get the crash, or subdivide the active set until you get to one script that causes the crash. I dont think it has anything to do with the scripts I get the same error when just doing this... /w gm &{template:default} {{name=Configurator}} {{ [Group Initative](!group-init --help) }}
Anthony V. said: The Aaron said: hmm.  One of those has a problem...  it will be a script with a chat event handler that isn't checking the message type.  Probably easiest to disable half the scripts, try your command, see if it crashes, then either flip the disabled and enabled to get the crash, or subdivide the active set until you get to one script that causes the crash. I dont think it has anything to do with the scripts I get the same error when just doing this... /w gm &{template:default} {{name=Configurator}} {{ [Group Initative](!group-init --help) }} Think Roll20 broke something with the update today.
1585693197
The Aaron
Roll20 Production Team
API Scripter
What character sheet are you using?
5e  OGL
1585700099
The Aaron
Roll20 Production Team
API Scripter
If you disable all scripts and just put this one in: on('ready',()=>log("API Started")); Do you still get the crash?
The Aaron said: If you disable all scripts and just put this one in: on('ready',()=>log("API Started")); Do you still get the crash? I narrowed in down to this script, any chance you can try take a quick look at it? on('chat:message', function(msg) { // ROLL LISTENER if(msg.playerid.toLowerCase() != "api" && msg.rolltemplate) { var cnamebase = msg.content.split("charname=")[1].split('{{')[0]; // Fixed line var cname = cnamebase ? cnamebase.replace('}}','').trim() : (msg.content.split("{{name=")[1]||'').split("}}")[0].trim(); var character = cname ? findObjs({name: cname, type: 'character'})[0] : undefined; if(["simple"].indexOf(msg.rolltemplate) > -1) { if(_.has(msg,'inlinerolls') && msg.content.indexOf("^{hit-dice-u}") > -1 && character) { handlehd(msg,character); } } } }); // CHECK CURRENT HD, DECREMENT HD, THEN APPLY HP var handlehd = function (msg, character) { var hd = findObjs({ type: 'attribute', characterid: character.id, name: "hit_dice" }, { caseInsensitive: true })[0]; var hp = findObjs({ type: 'attribute', characterid: character.id, name: "hp" }, { caseInsensitive: true })[0]; if (!hd || hd.get("current") === "" || hd.get("max") === "") { log("CHARACTER HAS NO HIT_DICE ATTRIBUTE OR HD CURRENT/MAX IS NULL"); sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HD attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>"); return; } else if (!hp || hp.get("current") === "" || hp.get("max") === "") { log("CHARACTER HAS NO HP ATTRIBUTE OR HP CURRENT/MAX IS NULL"); sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HP attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>"); return; } else { var curhd = parseInt(hd.get("current")); var newhd = curhd - 1; } var maxhp = parseInt(hp.get("max")); var curhp = parseInt(hp.get("current")); if (curhd === 0) { sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " has no HD remaining, HP were not applied." + "</span></div></div></div>"); } else if (curhp === maxhp) { sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " already at full HP, no HD used." + "</span></div></div></div>"); } else { hd.set({ current: newhd }); var result = msg.inlinerolls[2].results.total ? msg.inlinerolls[2].results.total : false; var newhp = curhp + result; if (result === false) { log("FAILED TO GET HD RESULT"); } else if (newhp > maxhp) { hp.set({ current: maxhp }); } else { hp.set({ current: newhp }); } } };
1585785552
The Aaron
Roll20 Production Team
API Scripter
Try this version: on('ready',()=>{ on('chat:message', function(msg) { // ROLL LISTENER if(msg.playerid.toLowerCase() != "api" && msg.rolltemplate && /charname=/i.test(msg.content) && /{{name=/i.test(msg.content) ) { var cnamebase = msg.content.split("charname=")[1].split('{{')[0]; // Fixed line var cname = cnamebase ? cnamebase.replace('}}','').trim() : (msg.content.split("{{name=")[1]||'').split("}}")[0].trim(); var character = cname ? findObjs({name: cname, type: 'character'})[0] : undefined; if(["simple"].indexOf(msg.rolltemplate) > -1) { if(_.has(msg,'inlinerolls') && msg.content.indexOf("^{hit-dice-u}") > -1 && character) { handlehd(msg,character); } } } }); // CHECK CURRENT HD, DECREMENT HD, THEN APPLY HP var handlehd = function (msg, character) { var hd = findObjs({ type: 'attribute', characterid: character.id, name: "hit_dice" }, { caseInsensitive: true })[0]; var hp = findObjs({ type: 'attribute', characterid: character.id, name: "hp" }, { caseInsensitive: true })[0]; if (!hd || hd.get("current") === "" || hd.get("max") === "") { log("CHARACTER HAS NO HIT_DICE ATTRIBUTE OR HD CURRENT/MAX IS NULL"); sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HD attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>"); return; } else if (!hp || hp.get("current") === "" || hp.get("max") === "") { log("CHARACTER HAS NO HP ATTRIBUTE OR HP CURRENT/MAX IS NULL"); sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HP attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>"); return; } else { var curhd = parseInt(hd.get("current")); var newhd = curhd - 1; } var maxhp = parseInt(hp.get("max")); var curhp = parseInt(hp.get("current")); if (curhd === 0) { sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " has no HD remaining, HP were not applied." + "</span></div></div></div>"); } else if (curhp === maxhp) { sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " already at full HP, no HD used." + "</span></div></div></div>"); } else { hd.set({ current: newhd }); var result = msg.inlinerolls[2].results.total ? msg.inlinerolls[2].results.total : false; var newhp = curhp + result; if (result === false) { log("FAILED TO GET HD RESULT"); } else if (newhp > maxhp) { hp.set({ current: maxhp }); } else { hp.set({ current: newhp }); } } }; const macrosToDelete = [ "Turn-180-Degrees", "Clear-Token", "Arrowed", "20+", "2GMlayer", "Bar1GRN", "Bar2BLU", "Bar3RD", "Blood", "Dead", "Desc|token", "Flying", "G-Attack", "Hasted", "Hiding", "Hold", "Light", "Rough-Terrain", "Sleep", "Slowed", "Stop!", "T-Defense", "Webbed", "Healing-Potion", "Opening", "Init-Local", "R-Rotate", "Pouches", "2Maplayer", "2Tokenlayer", "Pic-Chart", "Misc", "SWN", "Noises", "Chikuwa", "Ambience", "Music", "Animals", "Bards" ]; findObjs({ type: "macro" }).filter(m=>macrosToDelete.includes(m)) .forEach(m=>m.remove()); });
1585841995

Edited 1585842128
The Aaron said: Try this version: on('ready',()=>{ on('chat:message', function(msg) { // ROLL LISTENER if(msg.playerid.toLowerCase() != "api" && msg.rolltemplate && /charname=/i.test(msg.content) && /{{name=/i.test(msg.content) ) { var cnamebase = msg.content.split("charname=")[1].split('{{')[0]; // Fixed line var cname = cnamebase ? cnamebase.replace('}}','').trim() : (msg.content.split("{{name=")[1]||'').split("}}")[0].trim(); var character = cname ? findObjs({name: cname, type: 'character'})[0] : undefined; if(["simple"].indexOf(msg.rolltemplate) > -1) { if(_.has(msg,'inlinerolls') && msg.content.indexOf("^{hit-dice-u}") > -1 && character) { handlehd(msg,character); } } } }); // CHECK CURRENT HD, DECREMENT HD, THEN APPLY HP var handlehd = function (msg, character) { var hd = findObjs({ type: 'attribute', characterid: character.id, name: "hit_dice" }, { caseInsensitive: true })[0]; var hp = findObjs({ type: 'attribute', characterid: character.id, name: "hp" }, { caseInsensitive: true })[0]; if (!hd || hd.get("current") === "" || hd.get("max") === "") { log("CHARACTER HAS NO HIT_DICE ATTRIBUTE OR HD CURRENT/MAX IS NULL"); sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HD attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>"); return; } else if (!hp || hp.get("current") === "" || hp.get("max") === "") { log("CHARACTER HAS NO HP ATTRIBUTE OR HP CURRENT/MAX IS NULL"); sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HP attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>"); return; } else { var curhd = parseInt(hd.get("current")); var newhd = curhd - 1; } var maxhp = parseInt(hp.get("max")); var curhp = parseInt(hp.get("current")); if (curhd === 0) { sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " has no HD remaining, HP were not applied." + "</span></div></div></div>"); } else if (curhp === maxhp) { sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " already at full HP, no HD used." + "</span></div></div></div>"); } else { hd.set({ current: newhd }); var result = msg.inlinerolls[2].results.total ? msg.inlinerolls[2].results.total : false; var newhp = curhp + result; if (result === false) { log("FAILED TO GET HD RESULT"); } else if (newhp > maxhp) { hp.set({ current: maxhp }); } else { hp.set({ current: newhp }); } } }; const macrosToDelete = [ "Turn-180-Degrees", "Clear-Token", "Arrowed", "20+", "2GMlayer", "Bar1GRN", "Bar2BLU", "Bar3RD", "Blood", "Dead", "Desc|token", "Flying", "G-Attack", "Hasted", "Hiding", "Hold", "Light", "Rough-Terrain", "Sleep", "Slowed", "Stop!", "T-Defense", "Webbed", "Healing-Potion", "Opening", "Init-Local", "R-Rotate", "Pouches", "2Maplayer", "2Tokenlayer", "Pic-Chart", "Misc", "SWN", "Noises", "Chikuwa", "Ambience", "Music", "Animals", "Bards" ]; findObjs({ type: "macro" }).filter(m=>macrosToDelete.includes(m)) .forEach(m=>m.remove()); }); That solved the split issue but now hit dice apllication does not work :( thanks for taking the time out of your day to help me.
1585842294
The Aaron
Roll20 Production Team
API Scripter
Ok.  I'll have to do a bit better job of fixing it tonight.  =D
The Aaron said: Ok.  I'll have to do a bit better job of fixing it tonight.  =D Thank you, you're the best!