-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
94 lines (87 loc) · 3.12 KB
/
index.js
File metadata and controls
94 lines (87 loc) · 3.12 KB
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
87
88
89
90
91
92
93
94
require('dotenv').config();
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const { DisTube } = require('distube');
const { SpotifyPlugin } = require('@distube/spotify');
const { SoundCloudPlugin } = require('@distube/soundcloud');
const { YtDlpPlugin } = require('@distube/yt-dlp');
const fs = require('fs');
const config = require('./config.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
]
});
client.commands = new Collection();
client.config = config;
client.distube = new DisTube(client, {
leaveOnStop: true,
leaveOnFinish: true,
emitNewSongOnly: true,
emitAddSongWhenCreatingQueue: false,
emitAddListWhenCreatingQueue: false,
plugins: [
new SpotifyPlugin(),
new SoundCloudPlugin(),
new YtDlpPlugin()
],
ytdlOptions: {
quality: 'highestaudio',
highWaterMark: 1 << 25
}
});
// Komut Yükleyici
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
// Event Handler
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, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
// DisTube Events
const status = queue =>
`Ses: \`${queue.volume}%\` | Filtre: \`${queue.filters.names.join(', ') || 'Kapalı'}\` | Tekrar: \`${
queue.repeatMode ? (queue.repeatMode === 2 ? 'Tüm Liste' : 'Bu Şarkı') : 'Kapalı'
}\``;
client.distube
.on('playSong', (queue, song) =>
queue.textChannel.send({
embeds: [{
color: parseInt(config.embedColor.replace('#', ''), 16),
description: `${config.emojis.play} | ${config.messages.nowPlaying}\n${song.name}`,
fields: [
{ name: '🎵 Şarkıyı Açan', value: `${song.user}`, inline: true },
{ name: '⏱️ Süre', value: song.formattedDuration, inline: true },
{ name: '⚙️ Durum', value: status(queue), inline: false }
]
}]
})
)
.on('addSong', (queue, song) =>
queue.textChannel.send({
embeds: [{
color: parseInt(config.embedColor.replace('#', ''), 16),
description: `${config.emojis.success} | ${config.messages.addedToQueue}\n${song.name}`
}]
})
)
.on('error', (channel, e) => {
channel.send({
embeds: [{
color: parseInt(config.embedColor.replace('#', ''), 16),
description: `${config.emojis.error} | Bir hata oluştu: ${e.toString().slice(0, 1974)}`
}]
});
console.error(e);
});
client.login(config.token);