-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathskipto.js
55 lines (45 loc) · 1.74 KB
/
skipto.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
const { MessageEmbed } = require("discord.js");
const sendError = require("../util/error");
module.exports = {
info: {
name: "skipto",
description: "Skip to the selected queue number",
usage: "skipto <number>",
aliases: ["st"],
},
run: async function (client, message, args) {
if (!args.length || isNaN(args[0]))
return message.channel.send({
embed: {
color: "GREEN",
description: `**Usage**: \`${client.config.prefix}skipto <number>\``
}
}).catch(console.error);
const queue = message.client.queue.get(message.guild.id);
if (!queue) return sendError("There is no queue.",message.channel).catch(console.error);
if (args[0] > queue.songs.length)
return sendError(`The queue is only ${queue.songs.length} songs long!`,message.channel).catch(console.error);
queue.playing = true;
if (queue.loop) {
for (let i = 0; i < args[0] - 2; i++) {
queue.songs.push(queue.songs.shift());
}
} else {
queue.songs = queue.songs.slice(args[0] - 2);
}
try{
queue.connection.dispatcher.end();
}catch (error) {
queue.voiceChannel.leave()
message.client.queue.delete(message.guild.id);
return sendError(`:notes: The player has stopped and the queue has been cleared.: ${error}`, message.channel);
}
queue.textChannel.send({
embed: {
color: "GREEN",
description: `${message.author} ⏭ skipped \`${args[0] - 1}\` songs`
}
}).catch(console.error);
message.react("✅")
},
};