module.exports = { name: 'play', aliases: ['p'], category: 'Music', utilisation: '{prefix}play [name/URL]', async execute(client, message, args, Discord) { //queue const queue = client.player.createQueue(message.guild, { metadata: message }); const notInVoice = new Discord.MessageEmbed() .setColor("#ffe700") .setAuthor(`❌- You are not connected to any voice channel !`) if (!message.member.voice.channel) return message.channel.send({ embeds: [notInVoice] }); const notSameChannelEmbed = new Discord.MessageEmbed() .setColor("#ffe700") .setAuthor(`❌- You must be on the same voice channel as me !`) if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send({ embeds: [notSameChannelEmbed] }); const enterATitleEmbed = new Discord.MessageEmbed() .setColor("#ffe700") .setAuthor(`❌- You must enter a valid title !`) if (!args[0]) return message.channel.send({ embeds: [enterATitleEmbed] }); const UnableToJoinEmbed = new Discord.MessageEmbed() .setColor("#ffe700") .setAuthor(`❌- I am not able to join your voice channel, please check my permissions !`) const { channel } = message.member.voice; const permissions = channel.permissionsFor(message.client.user); if (!permissions.has("CONNECT") || !permissions.has("VIEW_CHANNEL")) return message.channel.send({ embeds: [UnableToJoinEmbed] }); try { await queue.connect(message.member.voice.channel); } catch { message.reply("Could not join your voice channel"); } const track = await client.player.search(args.join(' '), { requestedBy: message.author }); queue.addTrack(track.tracks[0]); queue.play(message, track, { firstResult: true }); }, };