-
Notifications
You must be signed in to change notification settings - Fork 16
/
bot.js
54 lines (42 loc) · 1.54 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
import { Client, Collection, GatewayIntentBits, Partials } from 'discord.js';
import { LeetCode } from 'leetcode-query';
import KeepAlive from './utility/KeepAlive.js';
import dotenv from 'dotenv';
import fs from 'fs';
dotenv.config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Channel
]
});
client.lc = new LeetCode()
client.commands = new Collection()
client.buttons = new Collection()
/**
* Load all the slash commands
*/
fs.readdirSync('./interactions/commands').filter(file => file.endsWith('.js')).forEach(file => {
import(`./interactions/commands/${file}`).then(({ default: command }) => {
client.commands.set(command.data.name, command);
}).catch(error => console.error(`Failed to load command ${file}:`, error));
});
fs.readdirSync('./interactions/buttons').filter(file => file.endsWith('.js')).forEach(file => {
import(`./interactions/buttons/${file}`).then(({ default: button }) => {
client.buttons.set(button.name, button);
}).catch(error => console.error(`Failed to load button ${file}:`, error));
});
/**
* Load all events
*/
fs.readdirSync('./events').filter(file => file.endsWith('.js')).forEach((file) => {
import(`./events/${file}`).then(({ default: event }) => {
client.on(file.split(".")[0], (...args) => event(...args))
})
})
KeepAlive();
client.login(process.env.TOKEN);