Installation
// Just import the class from Ruvyrias
const { Deezer } = require('ruvyrias');
Example usage basic bot
const { Client, GatewayIntentBits } = require('discord.js');
const { Deezer } = require('ruvyrias');
const deezer = new Deezer();
const RuvyriasOptions = {
library: 'discord.js',
defaultPlatform: 'dzsearch',
plugins: [deezer],
};
const nodes = [
{
name: 'local-node',
host: 'localhost',
port: 2333,
password: 'youshallnotpass',
},
];
// The entire code of a bot can be found at the main page, i'll not repeat all things here
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
});
client.ruvyrias = new Ruvyrias(client, nodes, RuvyriasOptions);
/**
* You can use the source property to search by name or it will use the defaultPlatform to search by name
* Links will work directly, and it serves to any platform, but plugins has to be loaded before (unless you have lavaSrc)
*/
const res = await client.ruvyrias.resolve({ query: 'alan walker alone', source: 'dzsearch', requester: message.author });
Class: Deezer
Represents the Deezer class, extending the base Plugin class.
Hierarchy
-
↳
Deezer
Table of contents
Constructors
Properties
Methods
- buildResponse
- buildUnresolved
- check
- decodeDeezerShareLink
- getAlbum
- getArtist
- getArtistTracks
- getData
- getPlaylist
- getQuerySong
- getTrack
- isDeezerShareLink
- load
- resolve
Constructors
constructor
• new Deezer(): Deezer
Returns
Overrides
Defined in
Properties
_resolve
• Private
_resolve: (__namedParameters
: ResolveOptions
) => any
Type declaration
▸ («destructured»
): any
Parameters
Name | Type |
---|---|
«destructured» | ResolveOptions |
Returns
any
Defined in
baseURL
• Private
baseURL: string
= DEEZER_PUBLIC_API
Defined in
name
• Readonly
name: string
The name of the plugin.
Inherited from
Defined in
ruvyrias
• Private
ruvyrias: Ruvyrias
Defined in
Methods
buildResponse
▸ buildResponse(loadType
, tracks
, playlistName?
, exceptionMsg?
): object
Builds a response object based on the specified parameters.
Parameters
Name | Type | Description |
---|---|---|
loadType | loadType | The load type of the response. |
tracks | any | The tracks associated with the response. |
playlistName? | string | The name of the playlist (optional). |
exceptionMsg? | string | The exception message (optional). |
Returns
object
- The constructed response object.
Defined in
buildUnresolved
▸ buildUnresolved(track
, requester
): Promise
<Track
>
Builds an unresolved track using the provided Deezer track object and requester.
Parameters
Name | Type | Description |
---|---|---|
track | DeezerTrack | The Deezer track object. |
requester | any | The requester for the track. |
Returns
Promise
<Track
>
- An unresolved Track instance representing the Deezer track.
Defined in
check
▸ check(url
): boolean
Checks if the provided URL matches the Deezer regex pattern.
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL to check. |
Returns
boolean
- True if the URL matches the Deezer regex pattern, false otherwise.
Defined in
decodeDeezerShareLink
▸ decodeDeezerShareLink(url
): Promise
<null
| string
>
Decodes a Deezer share link to obtain the original URL.
Parameters
Name | Type | Description |
---|---|---|
url | string | The Deezer share link to decode. |
Returns
Promise
<null
| string
>
- A promise that resolves to the original URL after decoding the Deezer share link.
Defined in
getAlbum
▸ getAlbum(id
, requester
): Promise
<object
| DeezerAlbum
>
Retrieves Deezer album tracks based on the album ID and requester.
Parameters
Name | Type | Description |
---|---|---|
id | string | The ID of the Deezer album. |
requester | any | The requester for the album tracks. |
Returns
Promise
<object
| DeezerAlbum
>
- A promise that resolves to Deezer album tracks based on the album ID.
Defined in
getArtist
▸ getArtist(id
, requester
): Promise
<object
| DeezerArtist
>
Retrieves information about a Deezer artist based on the provided ID and requester.
Parameters
Name | Type | Description |
---|---|---|
id | string | The ID of the Deezer artist. |
requester | any | The requester of the artist information. |
Returns
Promise
<object
| DeezerArtist
>
- A promise that resolves to the Deezer artist information.
Defined in
getArtistTracks
▸ getArtistTracks(deezerArtist
): Promise
<void
>
Retrieves additional tracks for a Deezer artist to ensure a comprehensive list.
Parameters
Name | Type | Description |
---|---|---|
deezerArtist | any | The Deezer artist object containing track information. |
Returns
Promise
<void
>
- A promise that resolves once additional tracks are loaded.
Defined in
getData
▸ getData(endpoint
): Promise
<unknown
>
Fetches data from the Deezer API based on the specified endpoint.
Parameters
Name | Type | Description |
---|---|---|
endpoint | string | The Deezer API endpoint to retrieve data from. |
Returns
Promise
<unknown
>
- A promise that resolves to the data fetched from the Deezer API.
Defined in
getPlaylist
▸ getPlaylist(id
, requester
): Promise
<object
>
Retrieves information about a Deezer playlist based on the provided ID and requester.
Parameters
Name | Type | Description |
---|---|---|
id | string | The ID of the Deezer playlist. |
requester | any | The requester of the playlist information. |
Returns
Promise
<object
>
- A promise that resolves to the Deezer playlist information.
Defined in
getQuerySong
▸ getQuerySong(query
, requester
): Promise
<unknown
>
Retrieves Deezer tracks based on a search query and requester.
Parameters
Name | Type | Description |
---|---|---|
query | any | The search query. |
requester | any | The requester for the tracks. |
Returns
Promise
<unknown
>
- A promise that resolves to Deezer tracks based on the search query.
Defined in
getTrack
▸ getTrack(id
, requester
): Promise
<object
| DeezerTrack
>
Retrieves information about a Deezer track based on the provided ID and requester.
Parameters
Name | Type | Description |
---|---|---|
id | string | The ID of the Deezer track. |
requester | any | The requester of the track information. |
Returns
Promise
<object
| DeezerTrack
>
- A promise that resolves to the Deezer track information.
Defined in
isDeezerShareLink
▸ isDeezerShareLink(url?
): boolean
Checks if the provided URL is a Deezer share link.
Parameters
Name | Type | Description |
---|---|---|
url? | string | The URL to check. |
Returns
boolean
- True if the URL is a Deezer share link, false otherwise.
Defined in
load
▸ load(ruvyrias
): Promise
<void
>
Overrides the load method of the Plugin class, enabling the Deezer plugin to interact with the Ruvyrias instance.
Parameters
Name | Type | Description |
---|---|---|
ruvyrias | Ruvyrias | The Ruvyrias instance. |
Returns
Promise
<void
>
Overrides
Defined in
resolve
▸ resolve(options
): Promise
<unknown
>
Resolves a track, album, playlist, or artist from Deezer based on the provided query, source, and requester.
Parameters
Name | Type | Description |
---|---|---|
options | ResolveOptions | The options for resolving a track. |
Returns
Promise
<unknown
>
- A promise that resolves to the result of the Deezer resolution.