diff --git a/scripts/main.js b/scripts/main.js new file mode 100644 index 0000000..faab1a7 --- /dev/null +++ b/scripts/main.js @@ -0,0 +1,27 @@ +import { PuckoPruttApi } from "./puckoapi/puckoapi.js" +import { puckocommand } from "./puckochat/commands.js" + +Hooks.on("init", async function() { + console.log("[puckoprutt] Hello Init"); + var puckoprutt = new PuckoPruttApi(); +}); + +Hooks.on("ready", async function() { + console.log("[puckoprutt] Hello Ready"); +}); + +Hooks.on("chatMessage", (log, message, data) => { + let to_send = ""; + let user = game.users.get(data.user); + let world = game.world.id; + + if(message[0] === "!") to_send = puckocommand(user, world, log, message.slice(1).split(" "), data); + + if(to_send !== "") { + ChatMessage.create({ + user: game.actors.getName("puckoprutt"), + speaker: ChatMessage.getSpeaker({actor: game.actors.getName("puckoprutt"), alias: "Almighty God"}), + content: to_send + }); + } +}); \ No newline at end of file