-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
47 lines (47 loc) · 1.82 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Import JavaScript modules
import { registerSettings } from './modules/Settings.js';
import { MODULE_NAME } from './modules/Settings.js';
import { MODULE_TITLE } from './modules/Settings.js';
import { MODULE_VERSION } from './modules/Settings.js';
import { initHooks, readyHooks, setupHooks } from './modules/Hooks.js';
import { BANNER } from './modules/Banner.js';
export let debugEnabled = 0;
// 0 = none, warnings = 1, debug = 2, all = 3
export let debug = (...args) => {
if (debugEnabled > 1) console.log(`DEBUG:${MODULE_NAME} | `, ...args);
};
export let log = (...args) => console.log(`${MODULE_NAME} | `, ...args);
export let warn = (...args) => {
if (debugEnabled > 0) console.warn(`${MODULE_NAME} | `, ...args);
};
export let error = (...args) => console.error(`${MODULE_NAME} | `, ...args);
export let timelog = (...args) => warn(`${MODULE_NAME} | `, Date.now(), ...args);
export let setDebugLevel = (debugText) => {
debugEnabled = { none: 0, warn: 1, debug: 2, all: 3 }[debugText] || 0;
// 0 = none, warnings = 1, debug = 2, all = 3
if (debugEnabled >= 3) CONFIG.debug.hooks = true;
};
/* ------------------------------------ */
/* Initialize module */
/* ------------------------------------ */
Hooks.once('init', async () => {
console.log(`${BANNER}`);
console.log(`
${MODULE_NAME} | Initializing ${MODULE_TITLE} - v${MODULE_VERSION}
`);
registerSettings();
initHooks();
});
/* ------------------------------------ */
/* Setup module */
/* ------------------------------------ */
Hooks.once('setup', function() {
setupHooks();
registerSettings();
});
/* ------------------------------------ */
/* When ready */
/* ------------------------------------ */
Hooks.once('ready', () => {
readyHooks();
});