Version 0.3.0 - Ajout des premières fonctionnalités du Player
This commit is contained in:
@@ -3,6 +3,7 @@ const { Embed, EmbedError } = require("../Embed");
|
||||
const { Player } = require("../../player/Player");
|
||||
const Finder = require("../../player/Finder");
|
||||
const { Playlist } = require("../../player/Playlist");
|
||||
const spotify = require("../../media/SpotifyInformation");
|
||||
|
||||
const command = new Command("play", "Jouer une musique à partir d'un lien dans un salon vocal", async (client, interaction) => {
|
||||
|
||||
@@ -11,7 +12,7 @@ const command = new Command("play", "Jouer une musique à partir d'un lien dans
|
||||
const url = interaction.options.get("url")
|
||||
const channel = interaction.member.voice.channel
|
||||
const now = interaction.options.getBoolean("now") || false
|
||||
await Finder.search(url.value).then((song) => {
|
||||
await Finder.search(url.value).then(async (song) => {
|
||||
if(!song) return new EmbedError("Impossible de trouver la musique à partir du lien donné ou des mots clés donnés").send(interaction)
|
||||
|
||||
const player = new Player(channel.guildId)
|
||||
@@ -22,35 +23,23 @@ const command = new Command("play", "Jouer une musique à partir d'un lien dans
|
||||
|
||||
// Check if song is playlist
|
||||
if(song instanceof Playlist) {
|
||||
|
||||
if(now) {
|
||||
player.readPlaylist(song, true)
|
||||
embed.setTitle('**Lecture immédiate**')
|
||||
} else {
|
||||
player.readPlaylist(song)
|
||||
embed.setTitle('**Ajout à la liste de lecture**')
|
||||
}
|
||||
|
||||
embed.setDescription('**Playlist : **' + song.songs.length + ' musiques')
|
||||
embed.addField('**Titre : **' + song.title, "")
|
||||
embed.addField('**Demandé par : **', interaction.member.user.username,)
|
||||
embed.addField('**Auteur : **', song.author)
|
||||
embed.addField('**Durée : **', song.readduration)
|
||||
embed.addField('**Auteur : **', song.author)
|
||||
embed.addField('**Provient de : **', song.type.replace(/^\w/, (c) => c.toUpperCase()))
|
||||
if(!song.type == "spotify") {
|
||||
embed.addField('**Durée : **', song.readduration)
|
||||
}
|
||||
embed.addField('**Lien : **', song.url)
|
||||
embed.addField(":warning: La récupération des musiques peut prendre du temps", "Veuillez patienter ... et éviter de lancer d'autres commandes")
|
||||
|
||||
|
||||
embed.setThumbnail(song.thumbnail)
|
||||
|
||||
} else {
|
||||
|
||||
if(now) {
|
||||
|
||||
player.play(song)
|
||||
embed.setTitle('**Lecture immédiate**')
|
||||
|
||||
} else {
|
||||
player.add(song)
|
||||
embed.setTitle('**Ajout à liste de lecture**')
|
||||
|
||||
}
|
||||
|
||||
|
||||
embed.setDescription('**Titre : **' + song.title)
|
||||
embed.addField('**Durée : **', song.readduration)
|
||||
embed.addField("**Artiste : **",song.author)
|
||||
@@ -60,9 +49,42 @@ const command = new Command("play", "Jouer une musique à partir d'un lien dans
|
||||
|
||||
}
|
||||
|
||||
if(now) {
|
||||
embed.setTitle("Lecture immédiate")
|
||||
} else {
|
||||
embed.setTitle("Ajoutée à la file d'attente")
|
||||
}
|
||||
|
||||
embed.send(interaction)
|
||||
|
||||
if(song instanceof Playlist) {
|
||||
if(song.type == "spotify") {
|
||||
song = await spotify.getTracks(song)
|
||||
}
|
||||
if(now) {
|
||||
player.readPlaylist(song, true)
|
||||
|
||||
} else {
|
||||
player.readPlaylist(song)
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
if(now) {
|
||||
|
||||
player.play(song)
|
||||
|
||||
|
||||
} else {
|
||||
player.add(song)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
embed.send(interaction)
|
||||
|
||||
})
|
||||
|
||||
}, [{type: "STRING", name: "url", description: "Recherche / Lien audio (Youtube / Soundclound / Spotify)", required: true},
|
||||
|
Reference in New Issue
Block a user