From 337e2e0296b6c70850c8a54f1e6b77b3c5ae1ab4 Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Sun, 8 Mar 2020 11:38:31 +0200 Subject: [PATCH] updated seek --- commands/seek.js | 11 +++++++---- struct/funcs/play.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/commands/seek.js b/commands/seek.js index cbf6f8e8..3000b28c 100644 --- a/commands/seek.js +++ b/commands/seek.js @@ -12,13 +12,16 @@ module.exports = { if (client.funcs.check(client, msg, command)) { let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url)); if (!args[1]) return msg.channel.send(`<:redx:674263474704220182> Correct usage: \`${prefix}seek \``); + let point = args[1]; const pos = parseInt(args[1]); - if (isNaN(pos)) return msg.channel.send('<:redx:674263474704220182> I\'m sorry, But you need to enter a valid __number__.'); - if (pos < 0) return msg.channel.send('<:redx:674263474704220182> The seeking point needs to be a positive number!'); - if (pos > data.length_seconds) return msg.channel.send(`<:redx:674263474704220182> The lenght of this song is ${data.length_seconds} seconds! You can't seek further than that!`); + if (isNaN(pos)) { + if (pos < 0) return msg.channel.send('<:redx:674263474704220182> The seeking point needs to be a positive number!'); + if (pos > data.length_seconds) return msg.channel.send(`<:redx:674263474704220182> The lenght of this song is ${data.length_seconds} seconds! You can't seek further than that!`); + point = pos; + } serverQueue.connection.dispatcher.end(); serverQueue.endReason = "seek"; - client.funcs.play(msg.guild, serverQueue.songs[0], client, msg, pos, false); + client.funcs.play(msg.guild, serverQueue.songs[0], client, msg, point, false); } } }; diff --git a/struct/funcs/play.js b/struct/funcs/play.js index e15dd76c..7be9240c 100644 --- a/struct/funcs/play.js +++ b/struct/funcs/play.js @@ -10,7 +10,7 @@ module.exports = async function (guild, song, client, seek, play) { return; } const dispatcher = serverQueue.connection - .play(await ytdl(song.url, { filter: "audio", highWaterMark: 1 << 25, volume: false }), { seek: seek, bitrate: 1024, passes: 10, volume: 1, bassboost: serverQueue.bass }) + .play(await ytdl(song.url, { filter: "audio", highWaterMark: 1 << 25, volume: false, begin: seek }), { seek: 0, bitrate: 1024, passes: 10, volume: 1, bassboost: serverQueue.bass }) .on("finish", () => { client.dispatcher.finish(client, serverQueue.endReason, guild); });