You should mark that as code (upper left corner, click the paragraph sign ¶ and select code ) so it's easier to understand what you are writing. This is your code, reformatted: on("chat:message", function (msg) { if (msg.type != "api") return; var command = msg.content { if (command == "!as") var n = msg.content sendChat("character|+character.id", n) } } Your primary problem is the missing ); which would close the on() function call. A few pointers. You should always use ; on the end of your lines. You should always put { } around statements following an if(). Don't put { } around things that aren't blocks controlled by conditionals like if(). You should also shun the == and != in favor of === and !== . The shorter versions do type coercion which can be unpredictable and is not commutative. You probably intended the following code: on("chat:message", function (msg) {
if (msg.type !== "api") {
return;
}
var parts=msg.content.split(' ');
var command = parts[0];
if (command === "!as") {
var character_name = parts[1];
var characters=findObjs({
type: 'character',
name: character_name
}, {caseInsensitive: true});
if(characters.length)
{
var saying = _.rest(parts,2).join(' ');
sendChat("character|"+characters[0].id, saying);
}
else
{
log("!as -- couldn't find character named '"+character_name+"'!");
}
}
});
You need to split the command out of the front of the contents, or find it and check the offset. I prefer the split method, so that's what I added. You also need to lookup the character by the name passed to !as as the second parameter. You can pass an object describing what you want to findObjs() to get an array of matching characters. If there are any, this uses the first one to speak, otherwise it logs the lack of a matching character. When I tried this, it worked, but I didn't get the portrait of the speaker the way I do with changing my speaking as. I highly recommend Javascript: the Good Parts, by Douglas Crockford [1] . I just read it and it really opened my eyes to Javascript's foibles. Additionally, JSLint can be a godsend for finding issues in your code. Hope that helps, and feel free to PM me with any JS issues or scripting help! =D [1] Javascript: the Good Parts, by Douglas Crockford