Skip to content

Commit

Permalink
[New] updated lyrics and nowplaying
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Oct 4, 2021
1 parent 3c97bcf commit 406ad43
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 3 deletions.
79 changes: 77 additions & 2 deletions commands/Music/lyrics.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,94 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { embedMessage } = require("../../modules/embedSimple");
const { Lyrics } = require("@discord-player/extractor");
const lyricsClient = Lyrics.init();

module.exports = {
name: "lyrics",
aliases: ["ly"],
args: true,
description: "Gets the lyrics of the current song or a song you pass",
usage: "ly || lyrics <optional song name>",
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);
const songString = args.join(" ");
let songTitle;

if (songString) {
songTitle = songString;
} else {
if (!queue)
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
"❌ There is no music playing to search for lyrics!"
),
],
});
if (queue.current.title) {
songTitle = queue.current.title;

const filterName = queue.current.title.indexOf("(");

if (filterName !== -1) {
songTitle = songTitle.slice(0, filterName);
}
}
}

try {
const lyrics = await lyricsClient.search(songTitle);
if (!lyrics)
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | I could not find any lyrics for this song!`
),
],
});

const lyricsEmbed = {
color: "#9dcc37",
title: `${lyrics.artist.name} - ${lyrics.title}`,
author: {
name: `${message.member.user.username}`,
icon_url: `${message.member.user.avatarURL()}`,
},
description: `${lyrics.lyrics}`,
thumbnail: {
url: `${lyrics.thumbnail}`,
},

timestamp: new Date(),
};

await message.channel.send({
embeds: [lyricsEmbed],
});
} catch (error) {
await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | I could not get the lyrics of this song!`
),
],
});
client.logger(error.message, "error");
}
},
data: new SlashCommandBuilder()
.setName("lyrics")
.setDescription("gets the lyrics of the current song")
.setDescription("Gets the lyrics of the current song or a song you pass")
.addStringOption((option) =>
option.setName("song").setDescription("song name")
),

async execute(interaction, client) {
await interaction.deferReply();
const songString = interaction.options.getString("song");
const lyricsClient = Lyrics.init();
const queue = client.player.getQueue(interaction.guild);
let songTitle;

Expand Down
32 changes: 31 additions & 1 deletion commands/Music/nowPlaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,39 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
name: "nowplaying",
aliases: ["now"],
args: false,
description: "Shows the current song playing",
usage: "now || nowplaying",
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

if (!queue || !queue.playing) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`${message.member.toString()}, ❌ | Nothing playing at the moment`
),
],
});
}

return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`🎵 | **${queue.nowPlaying()}** in [<#${
message.member.voice.channelId
}>]`
),
],
});
},
data: new SlashCommandBuilder()
.setName("nowplaying")
.setDescription("shows the current music name"),
.setDescription("Shows the current song playing"),

async execute(interaction, client) {
await interaction.deferReply();
Expand Down

0 comments on commit 406ad43

Please sign in to comment.