Last active
March 29, 2020 23:01
-
-
Save reckenrode/cf2cc891e022dcb6b0f7b2dcf1bea8f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on("chat:message", (msg) => { | |
const cmdName = "sroll"; | |
const params = msg.content.splitArgs(); | |
const cmd = params.shift().substring(1); | |
if(msg.type === "api" && cmd === cmdName) { | |
const to_whom = msg.who.split(" ")[0]; | |
const char_obj = findObjs({"type": "character", "name": msg.who})[0]; | |
if (char_obj === undefined) { | |
sendChat(`player|${msg.playerid}`, `/w ${to_whom} To send secret rolls, you must be using a character. Please switch to your character.`); | |
} else { | |
const skill = params.join(" "); | |
const who = playerIsGM(msg.playerid) ? `player|${msg.playerid}` : `character|${char_obj.id}`; | |
if (!playerIsGM(msg.playerid)) { | |
sendChat(who, `/w ${to_whom} Secret roll sent to GM: “1d20cs20cf1+(@{${msg.who}|${skill}})[${skill}]”.`); | |
} | |
sendChat(who, `/w gm &{template:rolls} {{charactername=${msg.who}}} {{header=${skill}}} {{subheader=Secret Check}} {{roll01=[[1d20cs20cf1+(@{${msg.who}|${skill}})[${skill}]]]}}`); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment