1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-14 03:30:18 +00:00
musix-oss/commands/seek.js

30 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-02-05 20:02:53 +00:00
module.exports = {
name: 'seek',
alias: 'none',
2020-03-12 11:56:31 +00:00
usage: '<point in song>',
2020-02-05 20:02:53 +00:00
description: 'Seek to a specific point in the currently playing song.',
onlyDev: true,
permission: 'MANAGE_MESSAGES',
category: 'music',
async execute(msg, args, client, Discord, prefix, command) {
const ytdl = require('ytdl-core');
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-14 16:38:02 +00:00
let data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
2020-03-12 11:56:31 +00:00
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${prefix}seek ${command.usage}\``);
2020-03-08 09:38:31 +00:00
let point = args[1];
2020-02-05 20:02:53 +00:00
const pos = parseInt(args[1]);
2020-03-08 09:38:31 +00:00
if (isNaN(pos)) {
2020-03-12 11:56:31 +00:00
if (pos < 0) return msg.channel.send(client.messages.seekingPointPositive);
2020-03-13 14:20:23 +00:00
let message;
message = client.messages.seekMax.replace("%LENGTH%", data.length_seconds);
if (pos > data.length_seconds) return msg.channel.send(message);
2020-03-08 09:38:31 +00:00
point = pos;
}
2020-03-14 16:38:02 +00:00
queue.connection.dispatcher.end();
queue.endReason = "seek";
client.funcs.play(msg.guild, queue.songs[0], client, msg, point, false);
2020-02-05 20:02:53 +00:00
}
}
};