
I wrote a script that *mostly* works. The intent is that it is supposed to find a folder named "....." and create 100 handouts within it, named "....". It creates the handouts at the bottom of the journal, not in the "....." folder. Can somebody see what is wrong? //Make 100 Handouts with the name "...." in the folder named "....."
on("chat:message", function(msg){
if(msg.type=="api" && msg.content=="!ManyHandouts"){
for (let i = 0; i < 100; i++) {
var folderName = ".....";
var handoutName = "....";
var handout = createObj("handout",{
name: handoutName
});
}
handout.set("notes",makeHTMLNote());
// Find the folder
var folder = findObjs({
_type: "handout",
name: folderName
})[0];
// Move the handout into the folder if the folder exists
if (folder) {
handout.set("infolder", folder.id);
sendChat("API", "Handout '" + handoutName + "' created and moved to folder '" + folderName + "'");
}
else {
sendChat("API", "Folder '" + folderName + "' not found.");
}
}
})
function makeHTMLNote(){
var body = `<div>foo</div><div>.</div><div>.</div>foo`;
return body;
}