diff --git a/src/commands/music/Lyrics.ts.txt b/src/commands/music/Lyrics.ts similarity index 88% rename from src/commands/music/Lyrics.ts.txt rename to src/commands/music/Lyrics.ts index 4273611ae..ea6ad68af 100644 --- a/src/commands/music/Lyrics.ts.txt +++ b/src/commands/music/Lyrics.ts @@ -1,11 +1,4 @@ -/* import { - ActionRowBuilder, - ButtonBuilder, - type ButtonInteraction, - ButtonStyle, - ComponentType, - type TextChannel, -} from 'discord.js'; +import { ActionRowBuilder, ButtonBuilder, type ButtonInteraction, ButtonStyle, ComponentType, type TextChannel, } from 'discord.js'; import { getLyrics } from 'genius-lyrics-api'; import { Command, type Context, type Lavamusic } from '../../structures/index'; @@ -14,9 +7,9 @@ export default class Lyrics extends Command { super(client, { name: 'lyrics', description: { - content: 'cmd.lyrics.description', - examples: ['lyrics'], - usage: 'lyrics', + content: 'cmd.lyrics.description', + examples: ['lyrics'], + usage: 'lyrics', }, category: 'music', aliases: ['ly'], @@ -40,14 +33,15 @@ export default class Lyrics extends Command { } public async run(client: Lavamusic, ctx: Context): Promise { - const player = client.manager.getPlayer(ctx.guild!.id); + let player = client.manager.getPlayer(ctx.guild!.id); + if (!player) return await ctx.sendMessage(ctx.locale('event.message.no_music_playing')) const embed = this.client.embed(); - const currentTrack = player.queue.current!; - const trackTitle = currentTrack.info.title.replace(/\[.*?\]/g, '').trim(); - const artistName = currentTrack.info.author.replace(/\[.*?\]/g, '').trim(); - const trackUrl = currentTrack.info.uri; - const artworkUrl = currentTrack.info.artworkUrl; + const track = player.queue.current!; + const trackTitle = track.info.title.replace(/\[.*?\]/g, '').trim(); + const artistName = track.info.author.replace(/\[.*?\]/g, '').trim(); + const trackUrl = track.info.uri; + const artworkUrl = track.info.artworkUrl; await ctx.sendDeferMessage(ctx.locale('cmd.lyrics.searching', { trackTitle })); @@ -173,7 +167,6 @@ export default class Lyrics extends Command { return pages; } } -*/ /** * Project: lavamusic @@ -184,4 +177,4 @@ export default class Lyrics extends Command { * This code is the property of Coder and may not be reproduced or * modified without permission. For more information, contact us at * https://discord.gg/ns8CTk9J3e - */ \ No newline at end of file + */ diff --git a/src/utils/genius-lyrics-api.d.ts b/src/utils/genius-lyrics-api.d.ts new file mode 100644 index 000000000..177debc18 --- /dev/null +++ b/src/utils/genius-lyrics-api.d.ts @@ -0,0 +1,36 @@ +declare module 'genius-lyrics-api' { + interface SearchOptions { + apiKey: string; + title: string; + artist?: string; + optimizeQuery?: boolean; + } + + interface Song { + id: number; + title: string; + url: string; + } + + interface LyricsOptions { + title: string; + artist: string; + } + + interface AlbumArtOptions { + title: string; + artist: string; + } + + interface SongByIdOptions { + id: number; + apiKey: string; + } + + export function search(options: SearchOptions): Promise; + export function getSong(options: { id: number; apiKey: string }): Promise; + export function getLyrics(options: LyricsOptions): Promise; + export function getAlbumArt(options: AlbumArtOptions): Promise; + export function getSongById(options: SongByIdOptions): Promise; + export function searchSong(options: SearchOptions): Promise; +}