Basically, you just put something like: on('ready',()=>{
/* your code */
}); So something like: on('ready', () => {
on("chat:message", function(msg) {
var cmdName = "!bskills";
var msgTxt = msg.content;
var msgWho = msg.who;
var msgSelected = msg.selected;
if(msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) {
if (msg.selected !== undefined) {
_.each(msg.selected, function(a) {
var token = getObj("graphic", a._id);
if (token.get("represents") != "") {
var character = getObj("character", token.get("represents"));
sendChat(msgWho, "/w " + msgWho + " &{template:default} {{name=Skill Checks Sent for " + character.get("name") + "}} ");
sendChat(msgWho, "/w gm &{template:default} {{name=Skill Checks for " + character.get("name") + "}} {{Arcana= [[1d20+" + getAttrByName(character.id, "arcana_bonus") + "]] | [[1d20+" + getAttrByName(character.id, "arcana_bonus") + "]]}} {{Deception = [[1d20+" + getAttrByName(character.id, "deception_bonus") + "]] | [[1d20+" + getAttrByName(character.id, "deception_bonus") + "]]}} {{Insight = [[1d20+" + getAttrByName(character.id, "insight_bonus") + "]] | [[1d20+" + getAttrByName(character.id, "insight_bonus") + "]]}} {{Intimidation = [[1d20+" + getAttrByName(character.id, "intimidation_bonus") + "]] | [[1d20+" + getAttrByName(character.id, "intimidation_bonus") + "]]}} {{Investigation = [[1d20+" + getAttrByName(character.id, "investigation_bonus") + "]] | [[1d20+" + getAttrByName(character.id, "investigation_bonus") + "]]}} {{Perception = [[1d20+" + getAttrByName(character.id, "perception_bonus") + "]] | [[1d20+" + getAttrByName(character.id, "perception_bonus") + "]]}} {{Persuasion = [[1d20+" + getAttrByName(character.id, "persuasion_bonus") + "]] | [[1d20+" + getAttrByName(character.id, "persuasion_bonus") + "]]}}");
}
});
} else {
sendChat(msgWho, "/w gm Needs to select a token");
sendChat(msgWho, "/w " + msgWho + " Select a token for the !bskills command");
}
};
});
});
Basically, when the 'ready' event fires, it registers your other function to handle 'chat:message' events.