
Hello I freely admit I am not a strong coder or an API expert, and this was done with the help of our new buddy, ChatGPT. I was looking to be able to show the image of monsters to players by using the already embedded images in the monster manual. I asked CHatGPT about this and it produced code that I tried , but it always returns monster could not be found in the monster manual - Any tips or ideas how to correct/improve/extend to other compendiums would be greatly appreciated (along with your patience : on("chat:message", function(msg) { if(msg.type === "api" && msg.content.indexOf("!showmonster") !== -1) { var parts = msg.content.split(" "); var monster = parts.slice(1).join(" "); var compendium = findObjs({_type: "compendium", title: "Monster Manual"})[0]; if(compendium) { var monsterPage = findObjs({_type: "page", name: monster, _parentID: compendium.id})[0]; if(monsterPage) { var imgSrc = monsterPage.get("imgsrc"); if(imgSrc) { sendChat("", "&{template:default} {{name=" + monster + "}} {{image=" + imgSrc + "}}"); } else { sendChat("", "/w gm The image source for " + monster + " could not be found."); } } else { sendChat("", "/w gm The monster " + monster + " could not be found in the Monster Manual Compendium."); } } else { sendChat("", "/w gm The Monster Manual Compendium could not be found."); } } });