-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
86 lines (72 loc) · 2.58 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const { token, database, prefix } = require('./config.json');
const fs = require("fs");
const mongoose = require('mongoose');
const { Player } = require("discord-player");
const { registerPlayerEvents } = require('./utils/playerEvents.js');
const { Client, GatewayIntentBits, Collection } = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageTyping,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildWebhooks,
],
});
client.prefix = prefix;
client.buttons = new Collection();
client.customCommands = new Collection();
client.commands = new Collection();
client.player = new Player(client, {
ytdlOptions: {
quality: "highestaudio",
highWaterMark: 1 << 25
}
})
registerPlayerEvents(client.player);
fs.readdirSync('./buttons/').forEach(folder => {
const buttons = fs.readdirSync(`./buttons/${folder}`).filter(file => file.endsWith('.js'));
for (const file of buttons) {
const button = require(`./buttons/${folder}/${file}`);
client.buttons.set(button.name, button);
//console.log(`-> Loaded button ${file}`);
};
});
fs.readdirSync('./commands/').forEach(folder => {
const commands = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commands) {
const command = require(`./commands/${folder}/${file}`);
client.commands.set(command.data.name, command);
//console.log(`-> Loaded command ${file}`);
};
});
fs.readdirSync('./custom-commands/').forEach(folder => {
const customCommandsFiles = fs.readdirSync(`./custom-commands/${folder}`).filter(file => file.endsWith('.js'));
for (const file of customCommandsFiles) {
const command = require(`./custom-commands/${folder}/${file}`);
client.customCommands.set(command.name, command);
//console.log(`=> Loaded custom command ${file}`);
};
});
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));
}
}
mongoose.connect(database
).then(() => {
console.log('Connected to MongoDB')
}).catch((err) => {
console.log(err)
})
client.login(token);