-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathremove.js
28 lines (26 loc) · 1.24 KB
/
remove.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
const { MessageEmbed } = require("discord.js");
const sendError = require("../util/error");
module.exports = {
info: {
name: "remove",
description: "Remove song from the queue",
usage: "rm <number>",
aliases: ["rm"],
},
run: async function (client, message, args) {
const queue = message.client.queue.get(message.guild.id);
if (!queue) return sendError("There is no queue.",message.channel).catch(console.error);
if (!args.length) return sendError(`Usage: ${client.config.prefix}\`remove <Queue Number>\``);
if (isNaN(args[0])) return sendError(`Usage: ${client.config.prefix}\`remove <Queue Number>\``);
if (queue.songs.length == 1) 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);
try{
const song = queue.songs.splice(args[0] - 1, 1);
sendError(`❌ **|** Removed: **\`${song[0].title}\`** from the queue.`,queue.textChannel).catch(console.error);
message.react("✅")
} catch (error) {
return sendError(`:notes: An unexpected error occurred.\nPossible type: ${error}`, message.channel);
}
},
};