This repository was archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
61 lines (49 loc) · 1.61 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { readdir } from "fs/promises"
import { Client, Collection, GatewayIntentBits } from "discord.js"
import config from "./config.json" assert { type: "json" }
const client = new Client({ intents: [GatewayIntentBits.Guilds] })
client.commands = new Collection()
client.contextMenus = new Collection()
client.buttons = new Collection()
const commandFolders = await readdir("./commands")
for (const folder of commandFolders) {
const commandFiles = await readdir(`./commands/${folder}`)
for (const file of commandFiles) {
const { default: command } = await import(
`./commands/${folder}/${file}`
)
client.commands.set(command.data.name, command)
}
}
const contextMenus = await readdir("./contextMenus")
for (const contextMenuFile of contextMenus) {
const { default: contextMenu } = await import(
`./contextMenus/${contextMenuFile}`
)
client.contextMenus.set(contextMenu.data.name, contextMenu)
}
const buttonFiles = await readdir("./buttons")
for (const buttonFile of buttonFiles) {
const { default: contextMenu } = await import(`./buttons/${buttonFile}`)
client.buttons.set(contextMenu.name, contextMenu)
}
const eventFiles = await readdir("./events")
for (const file of eventFiles) {
const { default: event } = await import(`./events/${file}`)
try {
if (event.once) {
client.once(event.name, (...args) => event.execute(...args))
} else {
client.on(event.name, (...args) => event.execute(...args))
}
} catch (error) {
console.error(error)
}
}
process.on("uncaughtException", (error) =>
console.error(
`There was an uncaught error:`,
error.stack ?? error.toString()
)
)
client.login(config.token)