forked from Kakashig1112/Beyond
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLyrics.ts
47 lines (46 loc) · 1.65 KB
/
Lyrics.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { MessageType } from "@adiwajshing/baileys";
import MessageHandler from "../../Handlers/MessageHandler";
import BaseCommand from "../../lib/BaseCommand";
import WAClient from "../../lib/WAClient";
import { IParsedArgs, ISimplifiedMessage } from "../../typings";
import Genius from "genius-lyrics";
import request from "../../lib/request";
export default class Command extends BaseCommand {
constructor(client: WAClient, handler: MessageHandler) {
super(client, handler, {
command: "lyrics",
description: "Gives you the lyrics of the given song.",
category: "music",
aliases: ["ly"],
usage: `${client.config.prefix}lyrics [song_name]`,
baseXp: 40,
});
}
run = async (
M: ISimplifiedMessage,
{ joined }: IParsedArgs
): Promise<void> => {
if (!this.client.config.geniusKey)
return void M.reply("No Genius Access Token set.");
if (!joined)
return void M.reply("Give me a song name to fetch the lyrics, Baka!");
const chitoge = joined.trim();
const Client = new Genius.Client(this.client.config.geniusKey);
const search = await Client.songs.search(chitoge);
if (search.error)
return void M.reply(`Couldn't find any matching song results.`);
const lyrics = await search[0].lyrics();
let text = `🎀 *Title: ${search[0].title}*\n\n`;
text += `🌐 *URL: ${search[0].url}*\n`;
M.reply(
await request.buffer(search[0].image),
MessageType.image,
undefined,
undefined,
text,
undefined
// eslint-disable-next-line @typescript-eslint/no-explicit-any
).catch((reason: any) => M.reply(`${text}`));
await M.reply(lyrics);
};
}