ruvyrias / Exports / AppleMusic
Installation
// Just import the class from Ruvyrias
const { AppleMusic } = require('ruvyrias');
Example usage basic bot
const { Client, GatewayIntentBits } = require('discord.js');
const { AppleMusic } = require('ruvyrias');
const applemusic = new AppleMusic({
countryCode: 'us',
apiKey: 'your-api-key'
});
const RuvyriasOptions = {
library: 'discord.js',
defaultPlatform: 'amsearch',
plugins: [applemusic],
};
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: 'amsearch', requester: message.author });
Class: AppleMusic
Represents the Apple Music class, extending the base Plugin class.
Hierarchy
-
↳
AppleMusic
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new AppleMusic(options
): AppleMusic
Parameters
Name | Type |
---|---|
options | Omit <AppleMusicOptions , "token" | "fetchURL" > |
Returns
Overrides
Defined in
plugins/applemusic/AppleMusic.ts:91
Properties
_resolve
• Private
_resolve: (__namedParameters
: ResolveOptions
) => any
Type declaration
▸ («destructured»
): any
Parameters
Name | Type |
---|---|
«destructured» | ResolveOptions |
Returns
any
Defined in
plugins/applemusic/AppleMusic.ts:90
baseURL
• Private
baseURL: "https://api.music.apple.com/v1/"
Defined in
plugins/applemusic/AppleMusic.ts:87
name
• Readonly
name: string
The name of the plugin.
Inherited from
Defined in
options
• Private
options: AppleMusicOptions
Defined in
plugins/applemusic/AppleMusic.ts:89
ruvyrias
• Private
ruvyrias: Ruvyrias
Defined in
plugins/applemusic/AppleMusic.ts:88
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
plugins/applemusic/AppleMusic.ts:315
buildUnresolved
▸ buildUnresolved(track
, requester
): Promise
<Track
>
Builds an unresolved track using the provided Apple Music track object and requester.
Parameters
Name | Type | Description |
---|---|---|
track | AppleMusicTrack | The Apple Music track object. |
requester | any | The requester for the track. |
Returns
Promise
<Track
>
- An unresolved Track instance representing the Apple Music track.
Defined in
plugins/applemusic/AppleMusic.ts:277
check
▸ check(url
): boolean
Checks if the provided URL matches the Apple Music regex pattern.
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL to check. |
Returns
boolean
- True if the URL matches the Apple Music regex pattern, false otherwise.
Defined in
plugins/applemusic/AppleMusic.ts:121
getAlbum
▸ getAlbum(url
, requester
): Promise
<object
>
Fetches data for an album from Apple Music.
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL of the album. |
requester | any | The requester of the data. |
Returns
Promise
<object
>
- A promise that resolves to the album data.
Defined in
plugins/applemusic/AppleMusic.ts:229
getArtist
▸ getArtist(url
, requester
): Promise
<object
>
Fetches data for an artist from Apple Music.
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL of the artist. |
requester | any | The requester of the data. |
Returns
Promise
<object
>
- A promise that resolves to the artist data.
Defined in
plugins/applemusic/AppleMusic.ts:203
getData
▸ getData(params
): Promise
<any
>
Fetches data from the Apple Music API based on the provided parameters.
Parameters
Name | Type | Description |
---|---|---|
params | string | The parameters to be included in the API request URL. |
Returns
Promise
<any
>
- A promise that resolves to the fetched data from the Apple Music API.
Defined in
plugins/applemusic/AppleMusic.ts:130
getPlaylist
▸ getPlaylist(url
, requester
): Promise
<object
>
Fetches data for a playlist from Apple Music.
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL of the playlist. |
requester | any | The requester of the data. |
Returns
Promise
<object
>
- A promise that resolves to the playlist data.
Defined in
plugins/applemusic/AppleMusic.ts:177
load
▸ load(ruvyrias
): Promise
<void
>
Overrides the load method of the Plugin class, enabling the Apple Music plugin to interact with the Ruvyrias instance.
Parameters
Name | Type | Description |
---|---|---|
ruvyrias | Ruvyrias | The Ruvyrias instance. |
Returns
Promise
<void
>
Overrides
Defined in
plugins/applemusic/AppleMusic.ts:110
resolve
▸ resolve(options
): Promise
<unknown
>
Resolves a track, album, playlist, or artist from Apple Music 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 Apple Music resolution.
Defined in
plugins/applemusic/AppleMusic.ts:148
searchSong
▸ searchSong(query
, requester
): Promise
<object
| AppleMusicTrack
>
Searches for a song on Apple Music.
Parameters
Name | Type | Description |
---|---|---|
query | string | The search query. |
requester | any | The requester of the data. |
Returns
Promise
<object
| AppleMusicTrack
>
- A promise that resolves to the search results.