Skip to main content
Version: v2.7.5

Player

Constructorโ€‹

new Magmastream.Player(options: PlayerOptions)
Parameter Type Description
selfDeafenbooleanIf the player should deaf itself.
selfMutebooleanIf the player should mute itself.
nodestring as NodeIdentifierThe node the Player uses.
textChannelstring as GuildTextChannelIDThe text channel the Player belongs to.
volumenumberThe initial volume the Player will use.
voiceChannelstring as GuildVoiceChannelIDThe voice channel the Player belongs to.
guildIdstring as GuildIDThe guild ID the Player belongs to.

Table of contentsโ€‹

Properties Methods
autoplayTriesconnect()
bandsdeleteSponsorBlock()
dynamicRepeatdestroy()
guildIddisconnect()
isAutoplayget()
managergetRecommended()
nodegetSponsorBlock()
nowPlayingMessagepause()
pausedplay()
playingprevious()
positionrestart()
queuesearch()
queueRepeatseek()
stateset()
textChannelsetAutoplay()
trackRepeatsetDynamicRepeat()
voiceChannelsetNowPlayingMessage()
voiceStatesetQueueRepeat()
volumesetSponsorBlock()
setTextChannel()
setTrackRepeat()
setVoiceChannel()
setVolume()
stop()

Propertiesโ€‹

autoplayTriesโ€‹

The number of times to try autoplay before emitting queueEnd.

Returns: number | 3 (default value)

bandsโ€‹

The equalizer bands array.

Returns: number[]

dynamicRepeatโ€‹

Whether the queue repeats and shuffles after each song.

Returns: boolean

guildIdโ€‹

The guild ID for the player.

Returns: string as GuildID

isAutoplayโ€‹

The autoplay state of the player.

Returns: boolean

managerโ€‹

The Manager for the player.

Returns: Manager

nodeโ€‹

The Node for the Player.

Returns: Node

nowPlayingMessageโ€‹

The now playing message for the player.

Returns: Message

pausedโ€‹

Whether the player is paused.

Returns: boolean

playingโ€‹

Whether the player is playing.

Returns: boolean

positionโ€‹

The time the player is in the track.

Returns: number

queueโ€‹

The Queue for the Player.

Returns: Queue

queueRepeatโ€‹

Whether the queue repeats the queue.

Returns: boolean

stateโ€‹

The current state of the player.

Returns: StateTypes

textChannelโ€‹

The text channel id for the player.

Returns: string as GuildTextChannelID

trackRepeatโ€‹

Whether the queue repeats the track.

Returns: boolean

voiceChannelโ€‹

The voice channel id for the player.

Returns: string as GuildVoiceChannelID

voiceStateโ€‹

The voice state object from Discord.

Returns: VoiceState

volumeโ€‹

The volume for the player.

Returns: number

Methodsโ€‹

connect()โ€‹

Connect to the voice channel.

Returns: this

deleteSponsorBlock()โ€‹

Deletes the sponsorblock for the player. This will remove all sponsorblock segments that have been set for the player.

Returns: Promise<this>

destroy()โ€‹

Destroys the player.

Returns: void

Parameter Type Description
disconnectbooleanIf true, disconnects the player from the voice channel before destroying it.

disconnect()โ€‹

Disconnects the player from the voice channel.

Returns: this

get()โ€‹

Retrieves custom data associated with a given key.

Returns: boolean

Parameter Type Description
keystringThe key to retrieve the data for.

getRecommended()โ€‹

Gets recommended tracks and returns an array of tracks.

Returns: Promise<track[]>

Parameter Type Description
trackTrackThe track to find recommendations for.
requesterUser | ClientUserThe user who requested the track.

getSponsorBlock()โ€‹

Gets the sponsorblock for the player.

Returns: Promise<SponsorBlockSegment[]>

pause()โ€‹

Pauses or resumes the current track.

Returns: this

Parameter Type Description
pausebooleanA boolean indicating whether to pause (true) or resume (false) the track.

play()โ€‹

Plays the next track.

If a track is provided, it will be played. Otherwise, the next track in the queue will be played.
If the queue is not empty, but the current track has not finished yet, it will be replaced with the provided track.

Returns: Promise<void>

const { Manager } = require('magmastream');

const manager = new Manager({
...ManagerOptions
})

const searchResponse = await manager.search('Never Gonna Give You Up');

const player = client.lavalink.create({
...PlayerOptions
});

player.connect()
player.queue.add(searchResponse.tracks);

player.play();

previous()โ€‹

Goes back to the previous song in the queue.

Returns: this

restart()โ€‹

Restarts the current track to the start.

If there's no current track and there are tracks in the queue, it plays the next track.

Returns: void

Same as Manager#search() but a shortcut on the player itself.

Returns: Promise<searchResult{}>

Parameter Type Description
querystring | searchQuery{}Query to search.
requesterUser | ClientUserThe user who requested the track.

seek()โ€‹

Seeks to the specified position in the current track.

Returns: this

Parameter Type Description
positionnumberThe position in milliseconds to seek to.

set()โ€‹

Set custom data.

Returns: void

Parameter Type Description
keystringThe key to set the data for.
valueunknownThe value to set the data to.

setAutoplay()โ€‹

Sets the autoplay-state of the player.

Autoplay is a feature that makes the player play a recommended track when the current track ends.

Returns: this

Parameter Type Description
autoplayStatebooleanWhether or not autoplay should be enabled.
botUserobjectThe user-object that should be used as the bot-user.
triesnumberThe number of times the player should try to find a recommended track if the first one doesn't work.

setDynamicRepeat()โ€‹

Sets the queue to repeat and shuffles the queue after each song.

Returns: this

Parameter Type Description
repeatbooleanWhether to repeat the queue or not
msnumberAfter how many milliseconds to trigger dynamic repeat.

setNowPlayingMessage()โ€‹

Sets the now playing message.

Returns: Message

Parameter Type Description
messageMessageThe message of the now playing message.

setQueueRepeat()โ€‹

Sets the queue repeat.

Returns: this

Parameter Type Description
repeatbooleanWhether to repeat the queue or not

setSponsorBlock()โ€‹

Sets the sponsorblock for the player. This will set the sponsorblock segments for the player to the given segments.

Returns: Promise<void>

Parameter Type Description
segmentsSponsorBlockSegment[]The sponsorblock segments to set. Defaults to ["sponsor", "selfpromo"] if not provided.

setTextChannel()โ€‹

Sets the player text channel.

This method updates the text channel associated with the player. It also emits a player state update event indicating the change in the channel.

Returns: this

Parameter Type Description
channelstring as GuildTextChannelIDThe new text channel ID.

setTrackRepeat()โ€‹

Sets the track repeat mode.

When track repeat is enabled, the current track will replay after it ends.
Disables queueRepeat and dynamicRepeat modes if enabled.

Returns: this

Parameter Type Description
repeatbooleanWhether to repeat the queue or not

setVoiceChannel()โ€‹

Sets the player voice channel.

Returns: this

Parameter Type Description
channelstring as GuildVoiceChannelIDThe new voice channel ID.

setVolume()โ€‹

Sets the player volume.

Returns: this

Parameter Type Description
volumenumberThe volume to set the player to. Must be between 0 and 100.

stop()โ€‹

Stops the current track, optionally give an amount to skip to, e.g 5 would play the 5th song.

Returns: this

Parameter Type Description
amountnumberThe amount of tracks to skip, e.g 5 would play the 5th song.