UNPKG

@delirius/welcard

Version:

WelCard is a lightweight and futuristic welcome card libary designed for WhatsApp Bots.

47 lines (44 loc) 1.35 kB
const axios = require("axios"); async function searchLyrics(term) { try { if (!term) { return "🟥 Provide the name of the song to search the lyrics"; } const geniusResponse = await axios.get( `https://letra-lime.vercel.app/genius?query=${term}`, ); const geniusData = geniusResponse.data; if (!geniusData.length) { return `🟨 Couldn't find any lyrics for "${term}"`; } const lyricsUrl = geniusData[0].url; const lyricsResponse = await axios.get( `https://letra-lime.vercel.app/lyrics?url=${lyricsUrl}`, ); const result = { status: '200', creador: 'Sareth', title: geniusData[0].title || "", fullTitle: geniusData[0].fullTitle || "", artist: geniusData[0].artist.name || "", artistUrl: geniusData[0].artist.url || "", id: geniusData[0].id || "", enpoint: geniusData[0].endpoint || "", instrumental: geniusData[0].instrumental, image: geniusData[0].image || "", url: geniusData[0].url || "", lyrics: lyricsResponse.data.lyrics || "", }; return result; } catch (error) { console.error(error); return { creador: "Sareth", status: "error", message: new Error(error).message, }; } } module.exports = { searchLyrics, };