-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
42 lines (39 loc) · 1.5 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
require("dotenv").config();
const Client = require("./Base/GiveawayBoat");
const client = new Client({
disableMentions: "everyone"
});
const fs = require("fs");
// handle events
fs.readdir("./events/", (err, files) => {
console.log(`Loading a total of ${files.length} events.`);
files.forEach(file => {
const eventName = file.split(".")[0];
console.log(`Loading Event: ${eventName}`);
const event = new (require(`./events/${file}`))(client);
client.on(eventName, (...args) => event.run(...args));
delete require.cache[require.resolve(`./events/${file}`)];
});
});
// handle commands
fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(dir => {
fs.readdir(`./commands/${dir}/`, (err, cmd) => {
cmd.forEach(file => {
if (!file.endsWith(".js")) return;
let Props = require(`./commands/${dir}/${file}`);
let commandName = file.split(".")[0];
console.log(`Loading Command: ${commandName}...`);
let props = new Props(client);
props.help.category = dir;
props.location = `./commands/${dir}/${file}`;
client.commands.set(props.help.name, props);
props.help.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
});
});
});
});
client.connect();