𝗗𝗔π—₯π—₯π—˜π—Ÿπ—Ÿ π— π—¨π—–π—›π—˜π—₯π—œ ⚑ commited on
Commit
fc10503
Β·
unverified Β·
1 Parent(s): 86880e6

Create search-lyrics.js

Browse files
Files changed (1) hide show
  1. plugins/search-lyrics.js +51 -0
plugins/search-lyrics.js ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const axios = require('axios');
2
+ const { cmd } = require('../command');
3
+
4
+ cmd({
5
+ pattern: "lyrics",
6
+ desc: "Get the lyrics of a song.",
7
+ category: "music",
8
+ react: "🎢",
9
+ filename: __filename
10
+ },
11
+ async (conn, mek, m, { from, reply, text }) => {
12
+ // Extract song title and artist from the message text
13
+ const [songTitle, artist] = text.split('|').map(str => str.trim());
14
+
15
+ if (!songTitle || !artist) {
16
+ return reply("Please provide the song title and artist in the format: `!lyrics <song_title> | <artist>`");
17
+ }
18
+
19
+ try {
20
+ // Replace spaces with '+' for URL encoding
21
+ const song = songTitle.replace(/\s+/g, '+');
22
+ const songArtist = artist.replace(/\s+/g, '+');
23
+
24
+ // Construct the API URL
25
+ const url = `https://api.davidcyriltech.my.id/lyrics?t=song a={songArtist}`;
26
+
27
+ // Fetch lyrics from the API
28
+ const response = await axios.get(url);
29
+ const data = response.data;
30
+
31
+ // Check if the response contains lyrics
32
+ if (data.lyrics) {
33
+ const lyricsMessage = `
34
+ 🎢 *Lyrics for*: songTitle by{artist}
35
+
36
+ ${data.lyrics}
37
+
38
+ *Lyrics provided by MR FRANK OFC*
39
+ `;
40
+ return reply(lyricsMessage);
41
+ } else {
42
+ return reply("Sorry, I couldn't find the lyrics for this song. Please check the song title and artist.");
43
+ }
44
+ } catch (e) {
45
+ console.error("Error fetching lyrics:", e);
46
+ reply("Β’ΟƒΟ…β„“βˆ‚ Ξ·ΟƒΡ‚ Ζ’Ρ”Ρ‚Β’Π½ Ξ± lΡƒrΞΉc. ρℓєαѕє тяу Ξ±gΞ±ΞΉΞ· ℓαтєя.");
47
+ }
48
+ });
49
+
50
+
51
+