-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpause.js
52 lines (48 loc) · 1.37 KB
/
pause.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
module.exports = {
name: "pause",
description: "Pause the currently playing music",
execute(message) {
if (!message.member.voice.channel) {
let pauseErrorEmbed = new MessageEmbed()
.setTitle("Pause")
.setDescription("You need to join a voice channel first!")
.setColor("#d32f2f");
return message.channel.send(pauseErrorEmbed).then((msg) => {
setTimeout(() => {
if (msg.deletable) {
msg.delete();
}
})
}).catch(console.error);
}
const serverQueue = message.client.queue.get(message.guild.id);
if (serverQueue && serverQueue.playing) {
serverQueue.playing = false;
serverQueue.connection.dispatcher.pause(true);
let pausedEmbed = new MessageEmbed()
.setTitle("Paused")
.setDescription(`The music has been paused by ${message.author}`)
.setColor(`#d32f2f`);
return serverQueue.textChannel.send(pausedEmbed)
.then((msg) => {
setTimeout(() => {
if (msg.deletable) {
msg.delete();
}
}, 10000);
})
.catch(console.error);
}
let pauseErrorEmbed = new MessageEmbed()
.setTitle("Pause")
.setDescription("There is nothing playing.")
.setColor("#d32f2f");
return message.channel.send(pauseErrorEmbed).then((msg) => {
setTimeout(() => {
if (msg.deletable) {
msg.delete();
}
})
}).catch(console.error);
}
};