lyrics support

This commit is contained in:
Snowflake107 2021-04-10 11:40:17 +05:45
parent e617d8acf3
commit facdc53755
2 changed files with 27 additions and 1 deletions

View file

@ -1,6 +1,6 @@
import { EventEmitter } from 'events';
import { Client, Collection, Snowflake, Collector, Message, VoiceChannel, VoiceState } from 'discord.js';
import { PlayerOptions, PlayerProgressbarOptions, QueueFilters } from './types/types';
import { LyricsData, PlayerOptions, PlayerProgressbarOptions, QueueFilters } from './types/types';
import Util from './utils/Util';
import AudioFilters from './utils/AudioFilters';
import { Queue } from './Structures/Queue';
@ -853,6 +853,17 @@ export class Player extends EventEmitter {
}
}
/**
* Gets lyrics of a song
* @param query Search query
*/
async lyrics(query: string) {
const data = await DP_EXTRACTORS.Lyrics(query);
if (Array.isArray(data)) return null;
return data as LyricsData;
}
private _handleVoiceStateUpdate(oldState: VoiceState, newState: VoiceState) {
const queue = this.queues.find((g) => g.guildID === oldState.guild.id);
if (!queue) return;

View file

@ -94,3 +94,18 @@ export interface PlayerProgressbarOptions {
queue?: boolean;
length?: number;
}
export interface LyricsData {
title: string;
id: number;
thumbnail: string;
image: string;
url: string;
artist: {
name: string;
id: number;
url: string;
image: string;
};
lyrics?: string;
}