-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (55 loc) · 2.49 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
const { Player } = require('discord-player');
const { Client, Intents, Collection } = require('discord.js');
const { readdirSync } = require('fs');
let client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_VOICE_STATES
]
});
client.config = require('./config');
client.player = new Player(client, client.config.opt.discordPlayer);
client.commands = new Collection();
let player = client.player
let events = readdirSync('./events/').filter(file => file.endsWith('.js'));
for (const file of events) {
let event = require(`./events/${file}`);
console.log(`-> Loaded event ${file.split('.')[0]}`);
client.on(file.split('.')[0], event.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)];
};
console.log(`-> Loaded commands...`);
readdirSync('./commands/').forEach(dirs => {
let commands = readdirSync(`./commands/${dirs}`).filter(files => files.endsWith('.js'));
for (const file of commands) {
let command = require(`./commands/${dirs}/${file}`);
client.commands.set(command.name.toLowerCase(), command);
delete require.cache[require.resolve(`./commands/${dirs}/${file}`)];
console.log(`-> Loaded command ${file.split('.')[0]}`);
};
});
player.on('trackStart', (queue, track) => {
if (!client.config.opt.loopMessage && queue.repeatMode !== 0) return;
queue.metadata.send({ content: `🎵 Music started playing: **${track.title}** -> Channel: **${queue.connection.channel.name}** 🎧` });
});
player.on('trackAdd', (queue, track) => {
queue.metadata.send({ content: `**${track.title}** added to playlist. ✅` });
});
player.on('botDisconnect', (queue) => {
queue.metadata.send({ content: 'Someone from the audio channel Im connected to kicked me out, the whole playlist has been cleared! ❌' });
});
player.on('channelEmpty', (queue) => {
queue.metadata.send({ content: 'I left the audio channel because there is no one on my audio channel. ❌' });
});
player.on('queueEnd', (queue) => {
queue.metadata.send({ content: 'All play queue finished, I think you can listen to some more music. ✅' });
});
if (client.config.TOKEN) {
client.login(client.config.TOKEN).catch(e => {
console.log("The Bot Token You Entered Into Your Project Is Incorrect Or Your Bot's INTENTS Are OFF!")
})
} else {
console.log("Please Write Your Bot Token Opposite The Token In The config.js File In Your Project!")
}