Skip to content

Commit

Permalink
[Hotfix] revert last changes since they are causing problems with int…
Browse files Browse the repository at this point in the history
…eractions
  • Loading branch information
naseif committed Nov 26, 2021
1 parent 4244d16 commit d6c7bbc
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 42 deletions.
57 changes: 56 additions & 1 deletion modules/Music.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -112,6 +160,13 @@ class Music {
});
}
}

if (queue.playing) {
searchSong.playlist
? await command.reply({ embeds: [playlistEmbed, musicEmbed] })
: await command.reply({ embeds: [musicEmbed] });
return;
}
}
}

Expand Down
44 changes: 3 additions & 41 deletions playerEvents/player.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down Expand Up @@ -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`);
});
};

0 comments on commit d6c7bbc

Please sign in to comment.