-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
43 lines (38 loc) · 2.17 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
const Discord = require('discord.js');
const Distube = require('distube');
require('dotenv').config();
const client = new Discord.Client();
client.distube = new Distube(client, { searchSongs: true, emitNewSongOnly: true, highWaterMark: 1<<25 });
client.voiceChannel = null;
client.commands = new Discord.Collection();
client.events = new Discord.Collection();
['commandHandler', 'eventHandler'].forEach(handler => {
require(`./handlers/${handler}`)(client, Discord);
});
const status = (queue) => `Volume: \`${queue.volume}%\` | Filter: \`${queue.filter || "Off"}\` | Loop: \`${queue.repeatMode ? queue.repeatMode == 2 ? "All Queue" : "This Song" : "Off"}\` | Autoplay: \`${queue.autoplay ? "On" : "Off"}\``;
client.distube
.on("playSong", (message, queue, song) => {
message.channel.send(`Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}\n${status(queue)}`);
client.voiceChannel = message.member.voice.channel;
})
.on("addSong", (message, queue, song) => message.channel.send(
`Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}`
))
.on("playList", (message, queue, playlist, song) => message.channel.send(
`Play \`${playlist.name}\` playlist (${playlist.songs.length} songs).\nRequested by: ${song.user}\nNow playing \`${song.name}\` - \`${song.formattedDuration}\`\n${status(queue)}`
))
.on("addList", (message, queue, playlist) => message.channel.send(
`Added \`${playlist.name}\` playlist (${playlist.songs.length} songs) to queue\n${status(queue)}`
))
// DisTubeOptions.searchSongs = true
.on("searchResult", (message, result) => {
let i = 0;
message.channel.send(`**Choose an option from below**\n${result.map(song => `**${++i}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")}\n*Enter anything else or wait 60 seconds to cancel*`);
})
// DisTubeOptions.searchSongs = true
.on("searchCancel", (message) => message.channel.send(`Searching canceled`))
.on("error", (message, e) => {
console.error(e)
message.channel.send("An error encountered: " + e);
});
client.login(process.env.DISCORD_TOKEN);