alaingilbert / Turntable-API

Allows you to create bots for turntable.fm
http://alaingilbert.github.com/Turntable-API/
MIT License
317 stars 97 forks source link

playlistRemove() #113

Closed samuri51 closed 12 years ago

samuri51 commented 12 years ago

ok so i'm using playlistAdd() to add songs to my queue, which works, and the bot plays the song immediately after adding which, which means it should be at index zero right? so i use playlistRemove() and it doesn't remove the song? anyone know how to get indexes on the playlist? or how to actually use this?

the goal: to remove the last song added to the queue when the command is used, this is to remove troll songs that accidently get added.

samuri51 commented 12 years ago

i finally figured it out, here is the fix

what this does is check who the current dj is, if its your bot it skips the song and removes the last item on their playlist, since you cant remove a song while its playing. if your bot is not the dj then the song was added at positon zero of their queue so that gets removed instead.

bot.playlistAll(function(playlist) {     
     if(checkWhoIsDj == USERID)
     {
     var remove = playlist.list.length - 1;
     bot.skip();     
     bot.playlistRemove(remove);
     }
     else
     {
     bot.playlistRemove(0);
     }})
samuri51 commented 12 years ago

i attached it to a text.match command too so it only executes when i call it.