2020-04-21 15:05:33 +00:00
|
|
|
// Copyright 2020 Emily J. / mudkipscience and contributors. Subject to the AGPLv3 license.
|
|
|
|
|
|
|
|
exports.conf = {
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
|
|
|
aliases: [],
|
|
|
|
permLevel: 'User',
|
|
|
|
requiredPerms: [],
|
|
|
|
cooldown: 2000
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.help = {
|
|
|
|
name: 'movesong',
|
|
|
|
category: 'Music',
|
|
|
|
description: 'Moves a song to a new position in the queue.',
|
|
|
|
usage: 'movesong [current position] [new position]',
|
|
|
|
parameters: '[current position] - The current position of the song you want to move'
|
|
|
|
}
|
|
|
|
|
|
|
|
const { getGuild } = require('../utils/music')
|
|
|
|
module.exports.run = (client, message, args, level) => {
|
|
|
|
const queue = getGuild(message.guild.id).queue
|
|
|
|
|
|
|
|
if (queue.length < 3) {
|
|
|
|
return message.channel.send('<:error:466995152976871434> Not enough songs are in the queue for this command to work!')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!args[0]) {
|
2020-04-22 04:50:00 +00:00
|
|
|
return client.userError(message, exports, 'Missing argument, the `current position` argument is required!')
|
2020-04-21 15:05:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!args[1]) {
|
2020-04-22 04:50:00 +00:00
|
|
|
return client.userError(message, exports, 'Missing argument, the `new position` argument is required!')
|
|
|
|
}
|
|
|
|
|
|
|
|
const oldPosition = +args[0]
|
|
|
|
const newPosition = +args[1]
|
|
|
|
|
|
|
|
if (isNaN(oldPosition) === true) {
|
2020-04-29 11:00:11 +00:00
|
|
|
return message.channel.send('<:error:466995152976871434> That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)')
|
2020-04-21 15:05:33 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 04:50:00 +00:00
|
|
|
if (isNaN(newPosition) === true) {
|
2020-04-29 11:00:11 +00:00
|
|
|
return message.channel.send('<:error:466995152976871434> That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)')
|
2020-04-21 15:05:33 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 11:00:11 +00:00
|
|
|
if (oldPosition < 1 || oldPosition >= queue.length) {
|
2020-04-29 11:21:34 +00:00
|
|
|
return message.channel.send('<:error:466995152976871434> Old position is not a valid song ID.')
|
2020-04-22 04:50:00 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 11:00:11 +00:00
|
|
|
if (newPosition < 1 || newPosition >= queue.length) {
|
2020-04-29 11:21:34 +00:00
|
|
|
return message.channel.send('<:error:466995152976871434> New position is not a valid song ID.')
|
2020-04-21 15:05:33 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 07:53:41 +00:00
|
|
|
const songName = queue[oldPosition].video.title
|
|
|
|
|
2020-04-21 15:05:33 +00:00
|
|
|
queue.splice(newPosition, 0, queue.splice(oldPosition, 1)[0])
|
|
|
|
|
2020-04-29 11:21:34 +00:00
|
|
|
message.channel.send(`<:success:466995111885144095> Moved **${songName}** from position \`${oldPosition}\` to \`${newPosition}\``)
|
2020-04-21 15:05:33 +00:00
|
|
|
}
|