Closed gizmo2342 closed 3 years ago
Thanks for getting back, do have an example on how to register it at the module init phase, the docs aren't that clear on that.
Just move it up into your 'init' callback function. Same for the other callback.
Hooks.on('init', () => {
game.specialDiceRoller = specialDiceRoller;
Hooks.on('chatMessage', (_: IChatLog, messageText: string, data: IChatData) => {
if (messageText !== undefined) {
for (const roller of rollers) {
if (roller.handlesCommand(messageText)) {
data.content = roller.rollCommand(messageText);
ChatMessage.create(data, {});
return false;
}
}
}
return true;
});
});
There are no real rules for that or at least I don't know any, but I try to avoid doing anything other than registering to 'init' and 'ready' hooks from the script itself. Everything else I prepare from inside either the init or the ready callback function.
Thanks!
Hi,
I recently had an issue in my game system, when trying to register to '/hex' chat commands myself. Your module registers it's callback handler before the modules 'init' phase, and therefore prevented my callback handler from being called. If there is no special reason for registering that early, I would prefer if you could move the registering call (index.ts:75) into your modules 'init' phase. I worked around the problem by registering early as well, but I'm not sure if the system scripts will always be processed before module scripts. So this could help avoid troublesome bug hunts.
Thanks in advance. Martin