-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (34 loc) · 973 Bytes
/
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 config = require("./config");
const fs = require("fs");
// Slash Commands
const { Client, Collection, Intents } = require("discord.js");
const slash = require("./util/slash");
// CLI
console.log("Loading intents");
// Checks
let finalIntents = [
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_MEMBERS,
];
const client = new Client({ intents: finalIntents });
module.exports = {
client: client,
};
// Commands
client.commands = new Collection();
const events = fs
.readdirSync("./events")
.filter((file) => file.endsWith(".js"));
events.forEach((event) => {
const eventFile = require(`./events/${event}`);
if (eventFile.oneTime) {
client.once(eventFile.event, (...args) => eventFile.run(...args));
} else {
client.on(eventFile.event, (...args) => eventFile.run(...args));
}
});
client.login(process.env.TOKEN);
console.log("Logged in!");