Reputation: 1
Seek command not working for the music bot, it's only replaying the song. The seek command was sospport to go to a time like 1:00 on the song if the user put it. I got no errors. Below is the code:
module.exports = {
name : 'seek',
description: 'Pick a time',
usage : "<time>",
run : async (client , message , args) => {
const serverQueue = message.client.queue.get(message.guild.id);
let channel = message.member.voice.channel;
if (!channel)return message.channel.send("Join a voice channel to play music!")
if (!serverQueue) return message.channel.send("No songs to seek");
try {
const curDuration = (serverQueue.songs[0].durationm * 60000) + ((serverQueue.songs[0].durations % 60000) * 1000);
const choiceDur = args.join(" ").split(":");
if (choiceDur.length < 2) return message.channel.send("No duration provided or invalid ?");
const optDurr = (parseInt(choiceDur[0], 10) * 60000) + ((parseInt(choiceDur[1], 10) % 60000) * 1000);
if (optDurr > curDuration) return message.channel.send("Your duration is too big");
serverQueue.songs.splice(1, 0, serverQueue.songs[0]);
return serverQueue.connection.dispatcher.end()
} catch (e) {
return message.channel.send(`Oh no an error occured : \`${e.message}\` try again later`)
}
}
}
Any help is appreciated !!!
I tried
serverQueue.connection.dispatcher.seek()
serverQueue.connection.dispatcher.seek(choiceDur)
serverQueue.connection.dispatcher.end(choiceDur)
serverQueue.connection.dispatcher.end()
Upvotes: 0
Views: 332
Reputation: 876
To be clear connection.dispatcher
is Stream follow docs there is no method called seek()
or end()
.
And to play song at specific times you should stop current streams and start new one at specific times.
Solution:
serverQueue.connection.play(serverQueue.currentSong, {seek: ms / 1000});
//serverQueue.currentSong is stream type
For more information: VoiceConnection#play takes a second StreamOptions argument. Note type of streaming not every type can be seek
Upvotes: 1