-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (37 loc) · 1.48 KB
/
index.js
File metadata and controls
46 lines (37 loc) · 1.48 KB
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 Discord = require("discord.js");
const { promisify } = require("util");
const readdir = promisify(require("fs").readdir);
const client = new Discord.Client();
client.config = require("./config.js");
process.on('uncaughtException', function (err) {
client.channels.get("571260960820690955").send(`ERROR: ` + err);
})
const init = async () => {
const evtFiles = await readdir("./events/");
console.log(`Loading a total of ${evtFiles.length} events.`);
evtFiles.forEach(file => {
const eventName = file.split(".")[0];
console.log(`Loading Event: ${eventName}`);
const event = require(`./events/${file}`);
client.on(eventName, event.bind(null, client));
});
const fs = require('fs')
client.on('message', message => {
const prefix = "!DBR!"
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const commandargs = message.content.split(' ').slice(1).join(' ');
const command = args.shift().toLowerCase();
client.channels.get("571260960820690955").send(`[${message.guild.name}] [${message.author.username}] >> ${prefix}${command} ${commandargs}`);
try {
let commandFile = require(`./commands/${command}.js`);
commandFile.run(client, message, args);
} catch (err) {
if (err instanceof Error && err.code === "MODULE_NOT_FOUND") {
return;
}
}
})
client.login(client.config.token);
};
init();