Song
Class representing a song.
Type Parameters
Section titled “Type Parameters”T = unknown
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Song<T>(info, options?): Song<T>;Create a Song
Parameters
Section titled “Parameters”SongInfo<T>
Raw song info
options?
Section titled “options?”ResolveOptions<T> = {}
Optional data
Returns
Section titled “Returns”Song<T>
Properties
Section titled “Properties”ageRestricted?
Section titled “ageRestricted?”ageRestricted?: boolean;Whether or not an age-restricted content
dislikes?
Section titled “dislikes?”dislikes?: number;Song dislike count
duration
Section titled “duration”duration: number;Song duration.
formattedDuration
Section titled “formattedDuration”formattedDuration: string;Formatted duration string (hh:mm:ss, mm:ss or Live).
id: string;Song ID.
isLive?
Section titled “isLive?”isLive?: boolean;Indicates if the song is an active live.
likes?
Section titled “likes?”likes?: number;Song like count
name?: string;Song name.
plugin
Section titled “plugin”plugin: | DisTubePlugin | null;The plugin that created this song
reposts?
Section titled “reposts?”reposts?: number;Song repost (share) count
source
Section titled “source”source: string;The source of this song info
stream
Section titled “stream”stream: | { playFromSource: true; url?: string;} | { playFromSource: false; song?: Song<T>;};Stream info
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ playFromSource: true; url?: string;}playFromSource
Section titled “playFromSource”playFromSource: true;The stream of this song will be played from source
url?: string;Stream URL of this song
Type Literal
Section titled “Type Literal”{ playFromSource: false; song?: Song<T>;}playFromSource
Section titled “playFromSource”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?
Section titled “thumbnail?”thumbnail?: string;Song thumbnail.
uploader
Section titled “uploader”uploader: object;Song uploader
name?: string;The name of the uploader.
url?: string;The URL of the uploader.
url?: string;Song URL.
views?
Section titled “views?”views?: number;Song view count
Accessors
Section titled “Accessors”member
Section titled “member”Get Signature
Section titled “Get Signature”get member(): GuildMember | undefined;User requested to play this song.
Returns
Section titled “Returns”GuildMember | undefined
Set Signature
Section titled “Set Signature”set member(member): void;Set the user that requested this song.
The value is ignored when it is not a valid guild member.
Parameters
Section titled “Parameters”member
Section titled “member”GuildMember | undefined
The member
Returns
Section titled “Returns”void
metadata
Section titled “metadata”Get Signature
Section titled “Get Signature”get metadata(): T;Optional metadata that can be used to identify the song. This is attached by the DisTube#play method.
Returns
Section titled “Returns”T
Set Signature
Section titled “Set Signature”set metadata(metadata): void;Set the metadata of the song.
Parameters
Section titled “Parameters”metadata
Section titled “metadata”T
The metadata
Returns
Section titled “Returns”void
playlist
Section titled “playlist”Get Signature
Section titled “Get Signature”get playlist(): | Playlist<unknown> | undefined;The playlist this song belongs to
Returns
Section titled “Returns”| Playlist<unknown>
| undefined
Set Signature
Section titled “Set Signature”set playlist(playlist): void;Set the playlist this song belongs to.
Throws
Section titled “Throws”DisTubeError When the value is not a Playlist
Parameters
Section titled “Parameters”playlist
Section titled “playlist”| Playlist<unknown>
| undefined
The playlist
Returns
Section titled “Returns”void
Get Signature
Section titled “Get Signature”get user(): User | undefined;User requested to play this song.
Returns
Section titled “Returns”User | undefined
Methods
Section titled “Methods”toString()
Section titled “toString()”toString(): string;The name of the song, or its url, or its id.
Returns
Section titled “Returns”string
The string representation of the song