2020-02-05 20:02:53 +00:00
module . exports = {
name : 'seek' ,
alias : 'none' ,
2020-02-24 18:41:40 +00:00
usage : '<point in song(seconds)>' ,
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 ) ) ;
if ( ! args [ 1 ] ) return msg . channel . send ( ` <:redx:674263474704220182> Correct usage: \` ${ prefix } seek <seeking point in seconds> \` ` ) ;
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 ) ) {
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 ;
}
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
}
}
} ;