-
Notifications
You must be signed in to change notification settings - Fork 5
/
commands.js
44 lines (41 loc) · 1.23 KB
/
commands.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
"use strict";
const {
journalPath,
customLocations
} = require("./utils");
const { push } = Array.prototype;
const tryRequire = () => {
delete require.cache[require.resolve(journalPath)];
try { return require(journalPath); }
catch(_) { return []; }
};
function journalOptions(...args) {
const argLen = args.length;
let tmp;
if (!argLen) {
if (!this.enabled) {
customLocations.length = 0;
push.apply(customLocations, tryRequire());
}
return this.cmd.message(`Journal ${(this.enabled = !this.enabled) ? "ena" : "disa"}bled`);
}
else switch((tmp = args[0]) && tmp.toLowerCase()) {
case "ui":
case "webui":
if (this.webui) {
this.webui.open();
}
else {
this.cmd.message(`<font color="#ff0000">WebUI dependency is not present.</font>`);
}
return;
}
if (this.currentContract !== 55) {
return this.cmd.message(`<font color="#ff0000">Travel journal must be open to save custom locations.</font>`);
}
const name = args.join(" ").split(":");
const province = name.length > 1 ? name.shift() : "";
this.newCustom = province ? `${name.join(":")}\t${province}` : name.join(":");
this.send("C_ADD_TELEPORT_TO_POS_LIST", 1, { name: "*\t*" });
}
module.exports = journalOptions;