let socket; Hooks.once("socketlib.ready", () => { socket = socketlib.registerModule("cass-a5e"); // Register funcs }); Hooks.once("init", () => { game.modules.get("cass-a5e").api = {}; game.modules.get("cass-a5e").api.socket = null; }); Hooks.once("ready", () => { if (game.user.isGM) { game.modules.get("cass-a5e").api.socket = socket; } });