2021-12-10 21:39:54 +05:00
const Command = require ( "../../base/Command.js" ) ,
Discord = require ( "discord.js" ) ,
Pagination = require ( "discord-paginationembed" ) ;
class Queue extends Command {
constructor ( client ) {
super ( client , {
name : "queue" ,
dirname : _ _dirname ,
enabled : true ,
guildOnly : true ,
aliases : [ "playlist" ] ,
memberPermissions : [ ] ,
botPermissions : [ "SEND_MESSAGES" , "EMBED_LINKS" ] ,
nsfw : false ,
ownerOnly : false ,
cooldown : 5000
} ) ;
}
async run ( message , args , data ) {
const voice = message . member . voice . channel ;
2021-12-11 01:11:50 +05:00
if ( ! voice ) return message . error ( "music/play:NO_VOICE_CHANNEL" ) ;
2021-12-10 21:39:54 +05:00
const queue = this . client . player . getQueue ( message ) ;
2021-12-11 01:11:50 +05:00
if ( ! queue ) return message . error ( "music/play:NOT_PLAYING" ) ;
2021-12-10 21:39:54 +05:00
2021-12-11 01:11:50 +05:00
if ( queue . tracks . length === 1 ) {
2021-12-10 21:39:54 +05:00
const embed = new Discord . MessageEmbed ( )
. setColor ( data . config . embed . color )
. setAuthor ( message . translate ( "music/queue:TITLE" ) , message . guild . iconURL ( { dynamic : true } ) )
. addField ( message . translate ( "music/np:CURRENTLY_PLAYING" ) , ` [ ${ queue . tracks [ 0 ] . title } ]( ${ queue . tracks [ 0 ] . url } ) \n *Requested by ${ queue . tracks [ 0 ] . requestedBy } * \n ` ) ;
return message . channel . send ( embed ) ;
2021-12-11 01:11:50 +05:00
} ;
2021-12-10 21:39:54 +05:00
let i = 0 ;
const FieldsEmbed = new Pagination . FieldsEmbed ( ) ;
FieldsEmbed . embed
. setColor ( data . config . embed . color )
. setAuthor ( message . translate ( "music/queue:TITLE" ) , message . guild . iconURL ( { dynamic : true } ) )
. addField ( message . translate ( "music/np:CURRENTLY_PLAYING" ) , ` [ ${ queue . tracks [ 0 ] . title } ]( ${ queue . tracks [ 0 ] . url } ) \n *Requested by ${ queue . tracks [ 0 ] . requestedBy } * \n ` ) ;
2021-12-11 01:11:50 +05:00
2021-12-10 21:39:54 +05:00
FieldsEmbed . setArray ( queue . tracks [ 1 ] ? queue . tracks . slice ( 1 , queue . tracks . length ) : [ ] )
. setAuthorizedUsers ( [ message . author . id ] )
. setChannel ( message . channel )
. setElementsPerPage ( 5 )
. setPageIndicator ( true )
. formatField ( "Queue" , ( track ) => ` ${ ++ i } . [ ${ track . title } ]( ${ track . url } ) \n *Requested by ${ track . requestedBy } * \n ` ) ;
2021-12-11 01:11:50 +05:00
2021-12-10 21:39:54 +05:00
FieldsEmbed . build ( ) ;
}
2021-12-11 01:11:50 +05:00
} ;
2021-12-10 21:39:54 +05:00
module . exports = Queue ;