-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (51 loc) · 1.67 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
const fs = require('fs');
const { Client, Collection, IntentsBitField:Intents, SlashCommandBuilder } = require('discord.js');
const { discord } = require('./config.json')
// define my scripts
const commandHandler = require('./classes/command');
const client = new Client({
intents: [
Intents.Flags.Guilds,
Intents.Flags.GuildMembers,
Intents.Flags.GuildMessages,
Intents.Flags.MessageContent
]
})
const options = {deploy: true, client: client}
// globals
if (!fs.existsSync('./database')) fs.mkdirSync('./database');
client.commands = new Collection();
globalThis.cmd = SlashCommandBuilder
globalThis.djsClient = client
globalThis.temporaryUserData = new Collection();
// handle allat
require('./backend/web')
const handler = new commandHandler('./commands')
handler.handle(options)
// handle events
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
// anti crash
process.on("unhandledRejection", (reason, p) => {
console.log("[antiCrash] :: Unhandled Rejection/Catch");
console.log(reason, p);
});
process.on("uncaughtException", (err, origin) => {
console.log("[antiCrash] :: Uncaught Exception/Catch");
console.log(err, origin);
});
process.on("uncaughtExceptionMonitor", (err, origin) => {
console.log("[antiCrash] :: Uncaught Exception/Catch (MONITOR)");
console.log(err, origin);
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
})
client.login(discord.token)