forked from umutxyp/MusicBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
83 lines (71 loc) · 2.81 KB
/
main.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
const { Player } = require('discord-player');
const { Client, Intents, Collection } = require('discord.js');
const fs = 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);
const player = client.player
const synchronizeSlashCommands = require('discord-sync-commands-v14');
client.commands = new Collection();
fs.readdir("./commands/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, {
name: commandName,
...props
});
console.log(`👌 Yüklendi slash komutu: ${commandName}`);
});
synchronizeSlashCommands(client, client.commands.map((c) => ({
name: c.name,
description: c.description,
options: c.options,
type: 'CHAT_INPUT'
})), {
debug: false
});
});
fs.readdir("./events", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
console.log(`👌 Event Yüklendi: ${eventName}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)];
});
});
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}** 🎧` }).catch(e => { })
});
player.on('trackAdd', (queue, track) => {
queue.metadata.send({ content: `**${track.title}** added to playlist. ✅` }).catch(e => { })
});
player.on('channelEmpty', (queue) => {
queue.metadata.send({ content: 'I left the audio channel because there is no one on my audio channel. ❌' }).catch(e => { })
});
player.on('queueEnd', (queue) => {
if(client.config.opt.voiceConfig.leaveOnTimer.status === true) {
setTimeout(() => {
if(queue.connection) queue.connection.disconnect();
}, client.config.opt.voiceConfig.leaveOnTimer.time);
}
queue.metadata.send({ content: 'All play queue finished, I think you can listen to some more music. ✅' }).catch(e => { })
});
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!")
}