Guest User

Untitled

a guest
Jul 7th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. const Discord = module.require("discord.js");
  2. const request = module.require("request");
  3.  
  4.  
  5. module.exports.run = async (bot, message, args) => {
  6. if(!message.member.voiceChannelID) {message.channel.send("Join a voice channel first 🎵"); return;}
  7. await request(`https://api.soundcloud.com/playlists/353139966.json?client_id=${bot.soundcloud}`, function (error, response, body) {
  8. if(error) return;
  9. var songs = JSON.parse(body).tracks;
  10. var songno = Math.floor(Math.random() * songs.length);
  11. var songc = message.member.voiceChannel;
  12. var song = songs[songno];
  13. songc.join().then(connection =>{bot.recentstream = connection.playStream(`${song.stream_url}?client_id=${bot.soundcloud}`);})
  14. let embed = new Discord.RichEmbed();
  15. embed.setAuthor("SoundCloud", "https://images.vexels.com/media/users/3/137412/isolated/preview/1802b9d8ce3c819eebe90a86bbb61077-soundcloud-icon-logo-by-vexels.png");
  16. embed.setDescription(song.description);
  17. embed.addField("Purchase:", `[Support The Artist](${song.purchase_url})`, true);
  18. embed.setColor('#ffa100');
  19. embed.setThumbnail(song.artwork_url);
  20. embed.setTitle(song.title);
  21. embed.setURL(song.permalink_url);
  22. embed.setFooter(song.created_at);
  23. message.channel.send({embed});
  24. });
  25. };
  26.  
  27. module.exports.help = {
  28. //What triggers the command:
  29. name: "playsong",
  30. //Description:
  31. desc: "- Plays a random official song"
  32. };
Advertisement
Add Comment
Please, Sign In to add comment