-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
59 lines (48 loc) · 1.48 KB
/
bot.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
const fs = require("fs");
const { Client, Intents, Collection } = require("discord.js");
const client = new Client({
intents: Object.values(Intents.FLAGS),
allowedMentions: { repliedUser: false, parse: ["roles", "users"] },
partials: ["CHANNEL", "GUILD_MEMBER", "MESSAGE", "REACTION", "USER"],
restTimeOffset: 50,
});
client.rebootFlg = 0;
require("./helpers/extends");
const config = require("./config.json");
client.commands = new Collection();
client.slash = new Collection();
client.cooldowns = new Collection();
const slashCommandFolders = fs.readdirSync("./slash");
for (const folder of slashCommandFolders) {
const commandFiles = fs
.readdirSync(`./slash/${folder}`)
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./slash/${folder}/${file}`);
client.slash.set(command.name, command);
}
}
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));
}
}
client.login(process.env.BOT_TOKEN);
process.on("uncaughtException", (e) => {
console.log(e);
client.channels
.fetch(config.errorLog)
.then((x) =>
x.send(
`\`\`\`js\n${require("util")
.inspect(e)
.slice(0, 1800)}\n\`\`\``
)
);
});