forked from SudhanPlayz/Discord-MusicBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
28 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
const { MessageEmbed } = require("discord.js"); | ||
const lyricsFinder = require("lyrics-finder"); | ||
const sendError = require("../util/error"); | ||
const splitlyrics = require("../util/pagination"); | ||
|
||
module.exports = { | ||
info: { | ||
name: "lyrics", | ||
description: "Get lyrics for the currently playing song", | ||
usage: "[lyrics]", | ||
aliases: ["ly"], | ||
}, | ||
info: { | ||
name: "lyrics", | ||
description: "Get lyrics for the currently playing song", | ||
usage: "[lyrics]", | ||
aliases: ["ly"], | ||
}, | ||
|
||
run: async function (client, message, args) { | ||
const queue = message.client.queue.get(message.guild.id); | ||
if (!queue) return sendError("There is nothing playing.",message.channel).catch(console.error); | ||
run: async function (client, message, args) { | ||
const queue = message.client.queue.get(message.guild.id); | ||
if (!queue) return sendError("There is nothing playing.", message.channel).catch(console.error); | ||
|
||
let lyrics = null; | ||
let lyrics = null; | ||
|
||
try { | ||
lyrics = await lyricsFinder(queue.songs[0].title, ""); | ||
if (!lyrics) lyrics = `No lyrics found for ${queue.songs[0].title}.`; | ||
} catch (error) { | ||
lyrics = `No lyrics found for ${queue.songs[0].title}.`; | ||
} | ||
try { | ||
lyrics = await lyricsFinder(queue.songs[0].title, ""); | ||
if (!lyrics) lyrics = `No lyrics found for ${queue.songs[0].title}.`; | ||
} catch (error) { | ||
lyrics = `No lyrics found for ${queue.songs[0].title}.`; | ||
} | ||
const splittedLyrics = splitlyrics.chunk(lyrics, 1024); | ||
|
||
let lyricsEmbed = new MessageEmbed() | ||
.setAuthor(`${queue.songs[0].title} — Lyrics`, "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif") | ||
.setThumbnail(queue.songs[0].img) | ||
.setColor("YELLOW") | ||
.setDescription(lyrics) | ||
.setTimestamp(); | ||
let lyricsEmbed = new MessageEmbed() | ||
.setAuthor(`${queue.songs[0].title} — Lyrics`, "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif") | ||
.setThumbnail(queue.songs[0].img) | ||
.setColor("YELLOW") | ||
.setDescription(splittedLyrics[0]) | ||
.setFooter(`Page 1 of ${splittedLyrics.length}.`) | ||
.setTimestamp(); | ||
|
||
if (lyricsEmbed.description.length >= 2048) | ||
lyricsEmbed.description = `${lyricsEmbed.description.substr(0, 2045)}...`; | ||
return message.channel.send(lyricsEmbed).catch(console.error); | ||
}, | ||
const lyricsMsg = await message.channel.send(lyricsEmbed); | ||
if (splittedLyrics.length > 1) await splitlyrics.pagination(lyricsMsg, message.author, splittedLyrics); | ||
}, | ||
}; |