1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-15 01:20:19 +00:00
musix-oss/src/commands/skipto.ts

26 lines
1.0 KiB
TypeScript
Raw Normal View History

2020-02-05 20:02:53 +00:00
module.exports = {
name: 'skipto',
alias: 'st',
2020-02-24 18:41:40 +00:00
usage: '<point in queue>',
2020-02-05 20:02:53 +00:00
description: 'Skip to a point in the queue',
onlyDev: false,
permission: 'MANAGE_MESSAGES',
category: 'music',
2020-03-21 17:49:25 +00:00
async execute(msg, args, client, Discord, command) {
2020-03-14 16:38:02 +00:00
const queue = client.queue.get(msg.guild.id);
2020-02-05 20:02:53 +00:00
if (client.funcs.check(client, msg, command)) {
2020-03-12 11:56:31 +00:00
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${command.usage}\``);
2020-03-24 10:02:07 +00:00
let point = parseInt(args[1]);
point = point - 1;
2020-03-12 11:56:31 +00:00
if (isNaN(point)) return msg.channel.send(client.messages.validNumber);
2020-03-14 16:38:02 +00:00
if (point > queue.songs.size) return msg.channel.send(client.messages.noSongs);
2020-03-21 17:49:25 +00:00
if (point < 0) return msg.channel.send(client.messages.cantSkipToCurrent);
for (let i = 0; i < point; i++) {
2020-03-14 16:38:02 +00:00
queue.songs.shift();
2020-02-05 20:02:53 +00:00
}
2020-03-14 16:38:02 +00:00
queue.endReason = "skipto";
queue.connection.dispatcher.end();
2020-02-05 20:02:53 +00:00
}
}
};