diff --git a/modules/Music.js b/modules/Music.js index 7db40a4..9091a07 100644 --- a/modules/Music.js +++ b/modules/Music.js @@ -96,9 +96,57 @@ class Music { ? queue.addTracks(searchSong.tracks) : queue.addTrack(searchSong.tracks[0]); + const username = command.member.user.username + ? command.member.user.username + : command.user.username; + + const avatar = command.member.user.avatarURL() + ? command.member.user.avatarURL() + : command.user.avatarURL(); + + const musicEmbed = { + color: "#9dcc37", + title: `${queue.playing ? "✅ Added to Queue" : "🎵 Playing"}`, + author: { + name: `${username}`, + icon_url: `${avatar || client.user.avatarURL()}`, + }, + description: `Song: **[${searchSong.tracks[0].title}](${searchSong.tracks[0].url})**`, + thumbnail: { + url: `${searchSong.tracks[0].thumbnail}`, + }, + fields: [ + { + name: "Author", + value: `${searchSong.tracks[0].author}`, + inline: true, + }, + { + name: "🕓 Duration", + value: `${searchSong.tracks[0].duration}`, + inline: true, + }, + ], + + timestamp: new Date(), + }; + + let playlistEmbed = { + color: "#9dcc37", + description: `✅ | Queued ${queue.tracks.length} Songs`, + }; + if (!queue.playing) { try { - return await queue.play(); + await queue.play(); + searchSong.playlist + ? await command.reply({ + embeds: [playlistEmbed, musicEmbed], + }) + : await command.reply({ + embeds: [musicEmbed], + }); + return; } catch (err) { logger(err.message, "error"); console.log(err); @@ -112,6 +160,13 @@ class Music { }); } } + + if (queue.playing) { + searchSong.playlist + ? await command.reply({ embeds: [playlistEmbed, musicEmbed] }) + : await command.reply({ embeds: [musicEmbed] }); + return; + } } } diff --git a/playerEvents/player.js b/playerEvents/player.js index 71b0b41..c9f008b 100644 --- a/playerEvents/player.js +++ b/playerEvents/player.js @@ -1,6 +1,5 @@ const { embedMessage } = require("../modules/embedSimple"); const { logger } = require("../modules/logger"); -const { MessageActionRow, MessageButton } = require("discord.js"); module.exports.playerEvents = (player) => { player.on("error", (queue, error) => { @@ -35,55 +34,18 @@ module.exports.playerEvents = (player) => { player.on("queueEnd", (queue) => { logger(`${queue.guild.name}: Queue has finished playing!`); }); - player.on("trackAdd", async (queue, track) => { + player.on("trackAdd", (queue, track) => { logger(`${queue.guild.name}: ${track.title} has been added!`); - - const musicEmbed = { - color: "#9dcc37", - title: `${queue.playing ? "✅ Added to Queue" : "🎵 Playing"}`, - description: `Song: **[${track.title}](${track.url})**`, - thumbnail: { - url: `${track.thumbnail}`, - }, - fields: [ - { - name: "Author", - value: `${track.author}`, - inline: true, - }, - { - name: "🕓 Duration", - value: `${track.duration}`, - inline: true, - }, - ], - - timestamp: new Date(), - }; - - return await queue.metadata.channel.reply({ embeds: [musicEmbed] }); }); player.on("trackEnd", (queue, track) => { logger(`${queue.guild.name}: ${track.title} has finished playing!`); }); - player.on("tracksAdd", async (queue, tracks) => { + player.on("tracksAdd", (queue, tracks) => { logger( `${queue.guild.name}: A playlist with ${tracks.length} songs has beed added!` ); - - let playlistEmbed = { - color: "#9dcc37", - description: `✅ | ${queue.playing ? "Queued" : "Added"} \`${ - tracks.length - }\` Songs from [${tracks[0].playlist.title}](${tracks[0].playlist.url})`, - }; - - return await queue.metadata.channel.reply({ - embeds: [playlistEmbed], - }); }); - - player.on("trackStart", async (queue, track) => { + player.on("trackStart", (queue, track) => { logger(`${queue.guild.name}: ${track.title} has started playing`); }); };