Skip to content

Commit

Permalink
v2.2.5
Browse files Browse the repository at this point in the history
- Update & fix Lyrics command
- Fixed Deezer to be show as "unknown" from NowPlaying command
- Update Mongoose package
  • Loading branch information
adh319 committed Oct 7, 2023
1 parent dc65ab9 commit 63f6e7a
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 47 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lunox",
"version": "2.2.0",
"version": "2.2.5",
"description": "Lunox by @adh319#9370",
"main": "sharder.js",
"scripts": {
Expand All @@ -12,10 +12,9 @@
"discord-hybrid-sharding": "^2.1.3",
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"google-search-url": "^0.1.8",
"moment": "^2.29.4",
"moment-duration-format": "^2.3.2",
"mongoose": "^7.5.4",
"mongoose": "^7.6.0",
"node-capitalize": "^1.0.0",
"node-cron": "^3.0.2",
"node-fetch": "^2.7.0",
Expand Down
127 changes: 85 additions & 42 deletions src/commands/Slash/Music/Lyrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,55 +31,98 @@ module.exports = {

const value = interaction.options.getString("search");

let song = value;
const currentSong = player.currentTrack.info;
const titles = currentSong.title.replace(/\(Official (Video|Audio|Music Video)\)/gi, "").trim();
const authors = currentSong.author.replace(/- Topic$/gi, "").trim();

const CurrentSong = player.currentTrack.info;
const titles = CurrentSong.title.replace("(Official Video)", "").replace("(Official Audio)", "");
const authors = CurrentSong.author.replace("- Topic", "");
const lyricEmbed = new EmbedBuilder().setColor(client.color);

if (!song && CurrentSong) song = `${titles} ${authors}`;
let lyricSong = null;
let lyricUrl = null;
let lyricThumbnail = null;
let lyricAuthor = null;
let lyricTitle = null;

try {
await fetch(`https://some-random-api.com/others/lyrics?title=${song}`)
.then((res) => res.json())
.then((data) => {
const lyricSong = data.lyrics;

if (!lyricSong) {
const lyricError = new EmbedBuilder().setColor(client.color).setDescription(`\`❌\` | Lyrics was not found.`);

return interaction.editReply({ embeds: [lyricError] });
}

const lyrics = lyricSong.length > 3905 ? lyricSong.substr(0, 3900) + "....." : lyricSong;
const titleSong = data.title;
const authorSong = data.author;

const gSearch = { query: `${titleSong} by ${authorSong} lyrics` };
const gLink = client.gsearch.craft(gSearch).url;
const urlSong = gLink.replace("http", "https");

const lyricEmbed = new EmbedBuilder()
.setAuthor({
name: `${titleSong} by ${authorSong} lyrics`,
iconURL: client.user.displayAvatarURL({ dynamic: true }),
})
.setColor(client.color)
.setDescription(`${lyrics}\n**[Click Here For More](${urlSong})**`)
.setThumbnail(CurrentSong.image)
.setFooter({
text: `Requested by ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
});

return interaction.editReply({ embeds: [lyricEmbed] });
});
if (value) {
await fetch(`https://weeb-api.vercel.app/genius?query=${value}`)
.then((res) => res.json())
.then(async (data) => {
const url = data[0].url;
const thumbnail = data[0].image;
const author = data[0].artist;
const title = data[0].title;

await fetch(`https://weeb-api.vercel.app/lyrics?url=${url}`)
.then((res) => res.json())
.then((lyrics) => {
lyricSong = lyrics.data;
});

lyricUrl = url;
lyricThumbnail = thumbnail;
lyricAuthor = author;
lyricTitle = title;
});
} else {
await fetch(`https://weeb-api.vercel.app/genius?query=${titles} ${authors}`)
.then((res) => res.json())
.then(async (data) => {
const url = data[0].url;
const thumbnail = data[0].image;
const author = data[0].artist;
const title = data[0].title;

await fetch(`https://weeb-api.vercel.app/lyrics?url=${url}`)
.then((res) => res.json())
.then((lyrics) => {
lyricSong = lyrics.data;
});

lyricUrl = url;
lyricThumbnail = thumbnail;
lyricAuthor = author;
lyricTitle = title;
});
}
} catch (err) {
console.log(err);
lyricEmbed.setDescription(`\`❌\` | No lyrics were found!`);

return interaction.editReply({ embeds: [lyricEmbed], ephemeral: true });
}

if (!lyricSong) {
lyricEmbed.setDescription(`\`❌\` | No lyrics were found!`);

const lyricError = new EmbedBuilder().setColor(client.color).setDescription(`\`❌\` | Lyrics was not found.`);
return interaction.editReply({ embeds: [lyricEmbed], ephemeral: true });
}

return interaction.editReply({ embeds: [lyricError] });
if (value) {
if (lyricSong.length > 4096) {
lyricEmbed.setDescription(`${lyricSong.slice(0, 3900)}\n\n[Click for more](${lyricUrl})`);
} else {
lyricEmbed.setDescription(`${lyricSong}\n\n[Click for more](${lyricUrl})`);
}
} else {
if (lyricSong.length > 4096) {
lyricEmbed.setDescription(`${lyricSong.slice(0, 3900)}\n\n[Click for more](${lyricUrl})`);
} else {
lyricEmbed.setDescription(`${lyricSong}\n\n[Click for more](${lyricUrl})`);
}
}

lyricEmbed
.setAuthor({
name: `${lyricTitle} by ${lyricAuthor} Lyrics`,
iconURL: client.user.displayAvatarURL({ size: 2048, dynamic: true }),
})
.setThumbnail(lyricThumbnail)
.setFooter({
text: `Requested by ${interaction.user.tag}`,
iconURL: interaction.user.displayAvatarURL({ size: 2048, dynamic: true }),
})
.setTimestamp();

return interaction.editReply({ embeds: [lyricEmbed] });
},
};
1 change: 1 addition & 0 deletions src/commands/Slash/Music/NowPlaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = {
else if (player.currentTrack.info.sourceName === "apllemusic") sources = "Apple Music";
else if (player.currentTrack.info.sourceName === "bandcamp") sources = "Bandcamp";
else if (player.currentTrack.info.sourceName === "http") sources = "HTTP";
else if (player.currentTrack.info.sourceName === "deezer") sources = "Deezer";

const embed = new EmbedBuilder()
.setAuthor({
Expand Down
2 changes: 0 additions & 2 deletions src/lunox.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { Client, Collection, GatewayIntentBits, Partials } = require("discord.js");
const { Poru } = require("poru");
const { ClusterClient, getInfo } = require("discord-hybrid-sharding");
const GSearch = require("google-search-url");

class MainClient extends Client {
constructor() {
Expand Down Expand Up @@ -34,7 +33,6 @@ class MainClient extends Client {
this.slashCommands = new Collection();
this.premium = new Collection();
this.dev = new Set();
this.gsearch = GSearch;

this.poru = new Poru(this, this.config.nodes, this.config.poruOptions, {
send: (guildId, payload) => {
Expand Down

0 comments on commit 63f6e7a

Please sign in to comment.