1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 07:41:56 +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');
const serverQueue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
let data = await Promise.resolve(ytdl.getInfo(serverQueue.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-04 21:17:33 +00:00
serverQueue.connection.dispatcher.end();
2020-03-03 20:24:41 +00:00
serverQueue.endReason = "seek";
2020-03-08 09:38:31 +00:00
client.funcs.play(msg.guild, serverQueue.songs[0], client, msg, point, false);
2020-02-05 20:02:53 +00:00
}
}
};