forked from wonderlandpark/wonderbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (52 loc) · 1.51 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
Better Discord. Wonder_Bot
Author(s) : wonderlandpark
(C) Team. Wonder. All rights reserved.
*/
/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
const tools = require("./tools");
const logger = tools.logger;
const config = require("./config");
const Bot = tools.bot.init;
const locale = require('./locale');
logger.log("Starting Up...", "Cyan", true);
process.title = `Wonder_Bot - Ver. ${require("./package.json").version}, ${
process.platform
}-${process.arch}`;
// Handlers
process.on("unhandledRejection", reason => {
logger.error(reason);
});
process.on("uncaughtException", err => {
logger.error(err.stack);
});
process.on("warning", err => {
logger.warn(err.stack);
});
process.on("exit", () => {
logger.WBerror(`Process has been Destroyed`);
logger.log("Bye", "Cyan");
console.log("\x1b[0m");
});
// Init
const WB = new Bot(config, (devMode = false));
// Protype
String.prototype.bind = function(parameters, lang) {
if (!lang) lang = 'ko';
let text = this;
const glob = text.match(/%(.*?)%/g);
if (glob) {
glob.forEach(key => {
const keyname = key.replace(/%/, "").replace(/%/, "");
text = text.replace(key, String(locale[lang].global[keyname]) || "");
});
}
const keys = text.match(/\{(.*?)\}/g);
if (!keys) return this;
keys.forEach(key => {
const keyname = key.replace(/\{/, "").replace(/\}/, "");
text = text.replace(key, String(parameters[keyname]) || "");
});
return text;
};