Wow, people are actually using that post. Great :) There are a couple of issues. I should probably post an updated version of that template using simpler syntax, but as it is you are missing a bunch of brackets in various places. Also you have no semi-colons to end lines anywhere, but that doesnt appear to be causing the problem. I havent checked that the code does what you want it to, but here's the corrected syntax for the format var DetermineEncounter = DetermineEncounter || (function () { // note the open bracket before the word function here 'use strict'; var version = '1.0', handleInput = function (msg) { log(msg); //rolling and sending the encounter table to the dm, eventually? if (msg.content.split(' ')[0] == "!encounter") { var dangerLevel = msg.content.split(" ")[1]; log('Danger level is ' + dangerLevel); var DieRolls = []; var i; var outMessage = ""; for (i = 0; i < 6; i++) { DieRolls += randomInteger(6); } CompareToTarget(dangerLevel, DieRolls); // also you have a function call with no function - i added an empty function below } // THIS WAS THE MAIN ERROR: you didnt close the if statement },
CompareToTarget = function(dangerLevel, DieRolls) { }, DetermineEncounter = function (dangerLevel, DieRolls) { for (var i = 0; i < DieRolls.length; i++) { log('Die roll is ' + DieRolls[i]) switch (i) { case 0: Time = 'Morning' if (DieRolls[i] <= dangerLevel) { encounterType = DetermineEncounter() } else { encounterType = 'No encounter' } log(encounterType) } //log(DieRolls[i]) // if(DieRolls[i] <= dangerLevel){ //log('there should be an encounter here') } }, // make sure every function before the final one before RETURN ends with }, - that comma is vital. registerEventHandlers = function () { on('chat:message', handleInput); // if you have any other on events, you can enter that here and create a function above, like handleInput, to intercept it. }; // this is the last fucntion before the return, so it gets a semi-colon to end it. return { RegisterEventHandlers: registerEventHandlers }; }()); // note the weird number of brackets here, you have to get this right. on("ready", function () { 'use strict'; DetermineEncounter.RegisterEventHandlers(); }); // also you'd got the wrong brackets ending this section too. The purpose of this template is so you can use the outer structure without changes, you just need to create inner functions.