-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
42 lines (37 loc) · 1.11 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
import fs from "fs";
import { config } from "dotenv";
import { Collection } from "discord.js";
import client from "./utils/client.js";
import checkForRoleUpdates from "./jobs/checkRoleUpdates.js";
// load envs
config();
const setupCommands = async () => {
client.commands = new Collection();
const commandFiles = fs
.readdirSync("./commands")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = await import(`./commands/${file}`);
client.commands.set(command.default.builder.name, command.default);
}
};
const setupEvents = async () => {
const eventFiles = fs
.readdirSync("./events")
.filter((file) => file.endsWith(".js"));
for (const file of eventFiles) {
const event = await import(`./events/${file}`);
if (event.default.once)
client.once(event.default.name, (...args) =>
event.default.execute(...args),
);
else
client.on(event.default.name, (...args) =>
event.default.execute(...args),
);
}
};
setupCommands();
setupEvents();
await client.login(process.env.TOKEN);
checkForRoleUpdates.execute();