Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = module.require("discord.js");
- const request = module.require("request");
- module.exports.run = async (bot, message, args) => {
- if(!message.member.voiceChannelID) {message.channel.send("Join a voice channel first 🎵"); return;}
- await request(`https://api.soundcloud.com/playlists/353139966.json?client_id=${bot.soundcloud}`, function (error, response, body) {
- if(error) return;
- var songs = JSON.parse(body).tracks;
- var songno = Math.floor(Math.random() * songs.length);
- var songc = message.member.voiceChannel;
- var song = songs[songno];
- songc.join().then(connection =>{bot.recentstream = connection.playStream(`${song.stream_url}?client_id=${bot.soundcloud}`);})
- let embed = new Discord.RichEmbed();
- embed.setAuthor("SoundCloud", "https://images.vexels.com/media/users/3/137412/isolated/preview/1802b9d8ce3c819eebe90a86bbb61077-soundcloud-icon-logo-by-vexels.png");
- embed.setDescription(song.description);
- embed.addField("Purchase:", `[Support The Artist](${song.purchase_url})`, true);
- embed.setColor('#ffa100');
- embed.setThumbnail(song.artwork_url);
- embed.setTitle(song.title);
- embed.setURL(song.permalink_url);
- embed.setFooter(song.created_at);
- message.channel.send({embed});
- });
- };
- module.exports.help = {
- //What triggers the command:
- name: "playsong",
- //Description:
- desc: "- Plays a random official song"
- };
Advertisement
Add Comment
Please, Sign In to add comment