forked from limxuan/music-bot-v12
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (39 loc) · 1.48 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
const fs = require('fs');
const discord = require('discord.js');
const client = new discord.Client({ disableMentions: 'everyone' });
const { Player } = require('discord-player');
const player = new Player(client);
client.player = player;
client.config = require('./config/bot.json');
client.emotes = require('./config/emojis.json');
client.filters = require('./config/filters.json');
client.commands = new discord.Collection();
fs.readdir('./events/', (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
console.log(`Loading event ${eventName}`);
client.on(eventName, event.bind(null, client));
});
});
fs.readdir('./player-events/', (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./player-events/${file}`);
let eventName = file.split(".")[0];
console.log(`Loading player event ${eventName}`);
client.player.on(eventName, event.bind(null, client));
});
});
fs.readdir('./commands/', (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
console.log(`Loading command ${commandName}`);
client.commands.set(commandName, props);
});
});
client.login(client.config.token_bot);