This repository has been archived by the owner on Oct 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.js
54 lines (45 loc) · 1.5 KB
/
bot.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
const Discord = require("discord.js");
const Enmap = require("enmap");
const fs = require("fs");
const path = require("path");
const client = new Discord.Client();
const appDir = path.dirname(require.main.filename);
require("console-stamp")(console, {
pattern: "dd/mm/yyyy HH:MM:ss"
});
const config = require(appDir + "/json/config.json");
const strings = require(appDir + "/json/strings.json");
const functions = require(appDir + "/functions/additional.js");
const args = process.argv.slice(2);
client.config = config;
client.strings = strings;
client.functions = functions;
client.discord = Discord;
client.appDir = appDir;
client.args = args;
fs.readdir(appDir + "/events/", (err, files) => {
if (err) {
return console.error(err);
}
files.forEach((file) => {
const event = require(`${appDir}/events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
});
});
client.commands = new Enmap();
fs.readdir(appDir + "/commands/", (err, files) => {
if (err) {
return console.error(err);
}
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`${appDir}/commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, props);
});
});
process.on("unhandledRejection", (reason) => {
console.error("Unhandled Rejection: " + reason);
});
client.login(config.token);