2019-10-13 17:52:51 +00:00
const YouTube = require ( "simple-youtube-api" ) ;
const he = require ( 'he' ) ;
2019-10-12 14:40:00 +00:00
module . exports = {
name : 'playlist' ,
usage : '[option]' ,
description : 'Save and load queues' ,
2019-10-31 18:29:26 +00:00
alias : 'pl' ,
2019-10-12 14:40:00 +00:00
cooldown : 10 ,
async execute ( message , args , client , Discord , prefix ) {
2019-10-31 18:29:26 +00:00
const embed = new Discord . RichEmbed ( )
. setTitle ( 'Options for playlist!' )
. addField ( 'play' , 'Play the guild specific queue.' , true )
. addField ( 'save' , 'Save the currently playing queue. Note that this will overwrite the currently saved queue!' , true )
. addField ( 'add' , 'Add songs to the playlist. Like song selection' , true )
. addField ( 'remove' , 'Remove songs from the playlist.' , true )
. addField ( 'list' , 'Display the playlist.' , true )
. setFooter ( ` how to use: ${ prefix } playlist <Option> <Optional option> ` )
. setAuthor ( client . user . username , client . user . displayAvatarURL )
. setColor ( '#b50002' )
2019-10-12 15:01:13 +00:00
const permissions = message . channel . permissionsFor ( message . author ) ;
2019-10-31 21:42:23 +00:00
if ( message . author . id !== client . config . devId ) {
2019-10-13 07:33:59 +00:00
if ( client . global . db . guilds [ message . guild . id ] . dj ) {
if ( ! message . member . roles . has ( client . global . db . guilds [ message . guild . id ] . djrole ) ) return message . channel . send ( ':x: You need the `DJ` role to modify or play the playlist!' ) ;
} else if ( ! permissions . has ( 'MANAGE_GUILD' ) ) return message . channel . send ( ':x: You need the `MANAGE_SERVER` permission to modify the playlist!' ) ;
2019-10-12 15:01:13 +00:00
}
2019-10-12 14:40:00 +00:00
if ( client . global . db . guilds [ message . guild . id ] . premium ) {
2019-10-31 18:29:26 +00:00
if ( args [ 1 ] ) {
const optionName = args [ 1 ] . toLowerCase ( ) ;
const option = client . playlistCmd . get ( optionName ) || client . playlistCmd . find ( cmd => cmd . aliases && cmd . aliases . includes ( optionName ) ) ;
if ( ! option ) return message . channel . send ( embed ) ;
try {
option . execute ( message , args , client , Discord , prefix ) ;
} catch ( error ) {
message . reply ( ` :x: there was an error trying to execute that option! Please contact support with \` ${ prefix } bug \` ! ` ) ;
const embed = new Discord . RichEmbed ( )
. setTitle ( ` Musix ${ error . toString ( ) } ` )
. setDescription ( error . stack . replace ( /at /g , '**at **' ) )
. setColor ( '#b50002' ) ;
client . fetchUser ( client . config . devId ) . then ( user => user . send ( embed ) ) . catch ( console . error ) ;
2019-10-31 19:10:24 +00:00
client . channels . get ( client . config . debug _channel ) . send ( embed ) ;
2019-10-31 18:29:26 +00:00
console . log ( error ) ;
2019-10-13 17:52:51 +00:00
}
2019-10-12 14:40:00 +00:00
} else {
return message . channel . send ( embed ) ;
}
} else return message . channel . send ( ":x: This is not a premium guild!" ) ;
} ,
} ;