✨ Update (v6.0.0)
This commit is contained in:
@@ -1,16 +1,36 @@
|
||||
const { QueryType } = require('discord-player');
|
||||
|
||||
module.exports = {
|
||||
name: 'play',
|
||||
aliases: ['p'],
|
||||
category: 'Music',
|
||||
utilisation: '{prefix}play [name/URL]',
|
||||
utilisation: '{prefix}play [song name/URL]',
|
||||
voiceChannel: true,
|
||||
|
||||
execute(client, message, args) {
|
||||
if (!message.member.voice.channel) return message.channel.send(`${client.emotes.error} - You're not in a voice channel !`);
|
||||
async execute(client, message, args) {
|
||||
if (!args[0]) return message.channel.send(`Please enter a valid search ${message.author}... try again ? ❌`);
|
||||
|
||||
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`${client.emotes.error} - You are not in the same voice channel !`);
|
||||
const res = await player.search(args.join(' '), {
|
||||
requestedBy: message.member,
|
||||
searchEngine: QueryType.AUTO
|
||||
});
|
||||
|
||||
if (!args[0]) return message.channel.send(`${client.emotes.error} - Please indicate the title of a song !`);
|
||||
if (!res || !res.tracks.length) return message.channel.send(`No results found ${message.author}... try again ? ❌`);
|
||||
|
||||
client.player.play(message, args.join(" "), { firstResult: true });
|
||||
const queue = await player.createQueue(message.guild, {
|
||||
metadata: message.channel
|
||||
});
|
||||
|
||||
try {
|
||||
if (!queue.connection) await queue.connect(message.member.voice.channel);
|
||||
} catch {
|
||||
await player.deleteQueue(message.guild.id);
|
||||
return message.channel.send(`I can't join the voice channel ${message.author}... try again ? ❌`);
|
||||
}
|
||||
|
||||
await message.channel.send(`Loading your ${res.playlist ? 'playlist' : 'track'}... 🎧`);
|
||||
|
||||
res.playlist ? queue.addTracks(res.tracks) : queue.addTrack(res.tracks[0]);
|
||||
|
||||
if (!queue.playing) await queue.play();
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user