-
Notifications
You must be signed in to change notification settings - Fork 9
/
global.js
46 lines (42 loc) Β· 1.35 KB
/
global.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
const fs = require('fs');
const { color } = require("./lib/function");
global.shp = " Γ"
global.config = require("./config.json");
global.sc = require('./lib/scrape');
global.tool = require('./lib/tools');
global.footer = "*_δΉ Simple WhatsApp - Bot_*"
const IkyyClient = require("ikyy");
global.rzky = new IkyyClient();
const Database = require('./lib/Database')
global.db = new Database()
global.conns = []
global.printLog = async(isCmd, sender, msg, body, groupName, isGc) => {
if(isCmd && isGc) {
return console.log(color("[ COMMAND GC ]", "aqua"),color(sender.split("@")[0], "lime"),color(body, "aqua"),"in",color(groupName, "lime"));
}
if(isCmd && !isGc) {
return console.log(color("[ COMMAND PC ]", "aqua"), color(sender.split("@")[0], "lime"), color(body, "aqua"));
}
}
global.reloadFile = (file, options = {}) => {
nocache(file, module => {
console.log(`File "${file}" se ha actualizado!\nReiniciando!`)
process.send("reset")
})
}
function nocache(module, cb = () => {}) {
fs.watchFile(require.resolve(module), async () => {
await uncache(require.resolve(module))
cb(module)
})
}
function uncache(module = '.') {
return new Promise((resolve, reject) => {
try {
delete require.cache[require.resolve(module)]
resolve()
} catch (e) {
reject(e)
}
})
}