-
Notifications
You must be signed in to change notification settings - Fork 0
/
volume.js
80 lines (72 loc) · 2.3 KB
/
volume.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
const { MessageEmbed } = require('discord.js');
module.exports = {
name: "volume",
description: "Change volume of currently playing voiceConnection",
execute(message, args) {
const serverQueue = message.client.queue.get(message.guild.id);
if (!message.member.voice.channel) {
let volumeErrorEmbed = new MessageEmbed()
.setTitle("Volume")
.setDescription("You need to join a voice channel first!")
.setColor("#d32f2f");
return message.channel.send(volumeErrorEmbed).then((msg) => {
if (msg.deletable) {
msg.delete();
}
}).catch(console.error);
}
if (!serverQueue) {
let volumeErrorEmbed = new MessageEmbed()
.setTitle("Volume")
.setDescription("There is nothing playing.")
.setColor("#d32f2f");
return message.channel.send(volumeErrorEmbed).then((msg) => {
if (msg.deletable) {
msg.delete();
}
}).catch(console.error);
}
if (!args[0]) {
let currentVolumeEmbed = new MessageEmbed()
.setTitle("Volume")
.setDescription(`The current volume is: **${serverQueue.volume}%**`);
return message.channel.send(currentVolumeEmbed).then((msg) => {
setTimeout(() => {
if (msg.deletable) {
msg.delete();
}
}, 10000);
}).catch(console.error);
}
if (isNaN(args[0])) {
let volumeErrorEmbed = new MessageEmbed()
.setTitle("Volume")
.setDescription("Please use a number to set volume.")
.setColor("#d32f2f");
return message.channel.send(volumeErrorEmbed).catch(console.error);
}
if (parseInt(args[0]) > 100 || parseInt(args[0]) < 0) {
let volumeErrorEmbed = new MessageEmbed()
.setTitle("Volume")
.setDescription("Please use a number to set volume.")
.setColor("#d32f2f");
return message.channel.send(volumeErrorEmbed).then((msg) => {
if (msg.deletable) {
msg.delete();
}
}).catch(console.error);
}
serverQueue.volume = args[0];
serverQueue.connection.dispatcher.setVolumeLogarithmic(args[0] / 100);
let volumeEmbed = new MessageEmbed()
.setTitle("Volume")
.setDescription(`Volume set to: **${args[0]}%**`);
return serverQueue.textChannel.send(volumeEmbed).then((msg) => {
setTimeout(() => {
if (msg.deletable) {
msg.delete();
}
}, 10000);
}).catch(console.error);
}
};