-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.js
72 lines (61 loc) · 1.96 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
64
65
66
67
68
69
70
71
72
const Discord = require("discord.js-selfbot");
const client = new Discord.Client();
const fs = require('fs');
const Enmap = require('enmap');
const utils = require('./utils');
const keepAlive = require("./server")
if (!process.env.TOKEN){
try{
const config = require("./config");
global.config = {'token': config.token, 'prefix': config.prefix};
} catch (e){
console.error("No config file found, create it or use environnement variables.");
process.exit(1);
};
} else{
if (!process.env.PREFIX) process.env.PREFIX="--";
global.config = {'token': process.env.TOKEN, 'prefix': process.env.PREFIX};
}
if (!process.env.ALLOWED){
try {global.config.allowed=require("./allowed.json").allowed}
catch (e){
global.config.allowed=[]
}
} else{
global.config.allowed=process.env.ALLOWED
}
keepAlive();
client.login(config.token)
utils.log("Logging in...");
/* ----------------------------------------------- */
global.queue = new Map();
client.commands = new Enmap();
/* ----------------------------------------------- */
var loaded = {events: [], commands: []};
var promise = new Promise((resolve) => {
fs.readdir('./events/', (err, files) => {
if (err) return console.error;
files.forEach(file => {
if (!file.endsWith('.js')) return;
const evt = require(`./events/${file}`);
let evtName = file.split('.')[0];
loaded.events.push(evtName)
client.on(evtName, evt.bind(null, client));
});
resolve();
});
});
fs.readdir('./commands/', async (err, files) => {
if (err) return console.error;
files.forEach(file => {
if (!file.endsWith('.js')) return;
let props = require(`./commands/${file}`);
props.names.list.forEach(name => {
client.commands.set(name, props);
})
let cmdName = file.split('.')[0];
loaded.commands.push(cmdName)
});
promise.then(() => {utils.log(`Table of commands and events :\n${utils.showTable(loaded)}`)});
});
/* --------------------------------------------------- */