Skip to content

Song

Class representing a song.

T = unknown

new Song<T>(info, options?): Song<T>;

Create a Song

SongInfo<T>

Raw song info

ResolveOptions<T> = {}

Optional data

Song<T>

ageRestricted?: boolean;

Whether or not an age-restricted content


dislikes?: number;

Song dislike count


duration: number;

Song duration.


formattedDuration: string;

Formatted duration string (hh:mm:ss, mm:ss or Live).


id: string;

Song ID.


isLive?: boolean;

Indicates if the song is an active live.


likes?: number;

Song like count


name?: string;

Song name.


plugin:
| DisTubePlugin
| null;

The plugin that created this song


reposts?: number;

Song repost (share) count


source: string;

The source of this song info


stream:
| {
playFromSource: true;
url?: string;
}
| {
playFromSource: false;
song?: Song<T>;
};

Stream info

{
playFromSource: true;
url?: string;
}
playFromSource: true;

The stream of this song will be played from source

url?: string;

Stream URL of this song


{
playFromSource: false;
song?: Song<T>;
}
playFromSource: false;

The stream of this song will be played from another song

song?: Song<T>;

The song that this song will be played from


thumbnail?: string;

Song thumbnail.


uploader: object;

Song uploader

name?: string;

The name of the uploader.

url?: string;

The URL of the uploader.


url?: string;

Song URL.


views?: number;

Song view count

get member(): GuildMember | undefined;

User requested to play this song.

GuildMember | undefined

set member(member): void;

Set the user that requested this song.

The value is ignored when it is not a valid guild member.

GuildMember | undefined

The member

void


get metadata(): T;

Optional metadata that can be used to identify the song. This is attached by the DisTube#play method.

T

set metadata(metadata): void;

Set the metadata of the song.

T

The metadata

void


get playlist():
| Playlist<unknown>
| undefined;

The playlist this song belongs to

| Playlist<unknown> | undefined

set playlist(playlist): void;

Set the playlist this song belongs to.

DisTubeError When the value is not a Playlist

| Playlist<unknown> | undefined

The playlist

void


get user(): User | undefined;

User requested to play this song.

User | undefined

toString(): string;

The name of the song, or its url, or its id.

string

The string representation of the song