-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
executable file
·50 lines (44 loc) · 1.51 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
/* eslint-disable import/no-dynamic-require */
/* eslint-disable global-require */
/* Mula Bot - Revamped in Node.js!
Created by Oishi Mula, 5/1/2022
*/
// Add required libs
const fs = require('node:fs');
const path = require('path');
const {
Client, Collection, Partials, GatewayIntentBits,
} = require('discord.js');
const secrets = require('./config/secrets');
// Create Discord client Instance
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Message, Partials.Reaction],
});
// To load commands
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.data.name, command);
}
// To load events
const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync('./events').filter((file) => file.endsWith('.js'));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
client.login(secrets.botToken);