-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcore.js
30 lines (19 loc) · 900 Bytes
/
core.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
import dotenv from 'dotenv'
dotenv.config()
import { Client, Intents, Collection, WebhookClient } from 'discord.js'
import fs from 'node:fs/promises'
import './db.js'
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
})
const config = JSON.parse(await fs.readFile('config.json'))
client.config = config
// -------------------- Webhook --------------------
const logsWebhook = new WebhookClient({ id: process.env.WEBHOOK_ID, token: process.env.WEBHOOK_TOKEN })
// -------------------- Command/Event handling --------------------
const cmds = ['aliases', 'commands']
const handlers = ['command', 'event']
cmds.forEach((x) => (client[x] = new Collection()))
handlers.forEach((x) => import(`./handlers/${x}.js`).then((module) => module.default(client, logsWebhook)))
// -------------------- Login --------------------
client.login(process.env.TOKEN)