Class : Player
Constructorโ
- Player : options
new Magmastream.Player(options: PlayerOptions)
| Parameter | Type | Description |
|---|---|---|
guildId | string as Guild.id | The guild ID the Player belongs to. |
textChannel | string as GuildTextChannel.id | The text channel the Player belongs to. |
voiceChannel | string as GuildVoiceChannel.id | The voice channel the Player belongs to. |
node | string as Node.identifier | The node the Player uses. |
volume | number | The initial volume the Player will use. |
selfMute | boolean | If the player should mute itself. |
selfDeafen | boolean | If the player should deaf itself. |
Table of contentsโ
Propertiesโ
autoplayTriesโ
The number of times to try autoplay before emitting queueEnd.
Return: number |
3 (default value)
bandsโ
The equalizer bands array.
Return: number[]
dynamicRepeatโ
Whether the queue repeats and shuffles after each song.
Return: boolean
filtersโ
The filters applied to the audio.
Return:
Filters
guildIdโ
The guild ID for the player.
isAutoplayโ
The autoplay state of the player.
Return: boolean
managerโ
The Manager for the player.
Return:
Manager
nodeโ
The Node for the Player.
Return:
Node
nowPlayingMessageโ
The now playing message for the player.
Return: Message
pausedโ
Whether the player is paused.
Return: boolean
playingโ
Whether the player is playing.
Return: boolean
positionโ
The time the player is in the track.
Return: number
queueโ
The Queue for the Player.
Return:
Queue
queueRepeatโ
Whether the queue repeats the queue.
Return: boolean
stateโ
The current state of the player.
Return: StateTypes
textChannelโ
The text channel id for the player.
Return: string as
GuildTextChannel.id
trackRepeatโ
Whether the queue repeats the track.
Return: boolean
voiceChannelโ
The voice channel id for the player.
Return: string as
GuildVoiceChannel.id
voiceStateโ
The voice state object from Discord.
Return: VoiceState
volumeโ
The volume for the player.
Return: number
Methodsโ
connect()โ
Connect to the voice channel.
Return: this
deleteSponsorBlock()โ
Deletes the sponsorblock for the player. This will remove all sponsorblock segments that have been set for the player.
destroy(disconnect)โ
Destroys the player.
Return: void
Parameter Type Description Optional disconnectboolean If true, disconnects the player from the voice channel before destroying it.
disconnect()โ
Disconnects the player from the voice channel.
Return: this
get(key)โ
Retrieves custom data associated with a given key.
Return: The data associated with the key, cast to the specified type.
Parameter Type Description Optional keystring The key to retrieve the data for.
getRecommended(track, requester)โ
Gets recommended tracks and returns an array of tracks.
Parameter Type Description Optional tracktrack{}The track to find recommendations for. requesterUser|ClientUserThe user who requested the track.
getSponsorBlock()โ
Gets the sponsorblock for the player.
Return: Promise<
sponsorBlockSegment[]>
pause()โ
Pauses or resumes the current track.
Return: this
Parameter Type Description Optional pauseboolean A 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.
- Start playing after add track to queue
- Start playing with track
- Start playing with play options
- Start playing with track and options
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();
| Parameter | Type | Optional |
|---|---|---|
track | track{} | unresolvedTrack{} |
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.play(searchResponse.tracks[0]);
| Parameter | Type | Optional |
|---|---|---|
options | playOptions{} |
| Parameter | Type | Optional |
|---|---|---|
track | track{} | UnresolvedTrack | |
options | playOptions{} |
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.play(searchResponse.tracks[0], {
...PlayOptions
});
previous()โ
Goes back to the previous song in the queue.
Return: 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.Return: void
search(query, requester)โ
Same as Manager#search() but a shortcut on the player itself.
Return: Promise<
searchResult{}>
Parameter Type Description Optional querystring | searchQuery{}Query to search. requesterUser|ClientUserThe user who requested the track.
seek(position)โ
Seeks to the specified position in the current track.
Return: this
Parameter Type Description Optional positionnumber The position in milliseconds to seek to.
set(key, value)โ
Set custom data.
Return: void
Parameter Type Description Optional keystring The key to set the data for. valueunknown The value to set the data to.
setAutoplay(autoplayState, botUser, tries)โ
Sets the autoplay-state of the player.
Autoplay is a feature that makes the player play a recommended track when the current track ends.Return: this
Parameter Type Description Optional autoplayStateboolean Whether or not autoplay should be enabled. botUserobject The user-object that should be used as the bot-user. triesnumber The number of times the player should try to find a recommended track if the first one doesn't work.
setDynamicRepeat(repeat, ms)โ
Sets the queue to repeat and shuffles the queue after each song.
Return: this
Parameter Type Description Optional repeatboolean Whether to repeat the queue or not msnumber After how many milliseconds to trigger dynamic repeat.
setNowPlayingMessage(message)โ
Sets the now playing message.
Return: Message
Parameter Type Description Optional messageMessage The message of the now playing message.
setQueueRepeat(repeat)โ
Sets the queue repeat.
Return: this
Parameter Type Description Optional repeatboolean Whether to repeat the queue or not
setSponsorBlock(segments)โ
Sets the sponsorblock for the player. This will set the sponsorblock segments for the player to the given segments.
Parameter Type Description Optional segmentssponsorBlockSegment[]The sponsorblock segments to set. Defaults to ["sponsor", "selfpromo"]if not provided.
setTextChannel(channel)โ
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.Return: this
Parameter Type Description Optional channelstring as GuildTextChannel.idThe new text channel ID.
setTrackRepeat(repeat)โ
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.Return: this
Parameter Type Description Optional repeatboolean Whether to repeat the queue or not
setVoiceChannel(channel)โ
Sets the player voice channel.
Return: this
Parameter Type Description Optional channelstring as GuildVoiceChannel.idThe new voice channel ID.
setVolume(volume)โ
Sets the player volume.
Return: this
Parameter Type Description Optional volumenumber The volume to set the player to. Must be between 0 and 100.
stop(amount)โ
Stops the current track, optionally give an amount to skip to, e.g 5 would play the 5th song.
Return: this
Parameter Type Description Optional amountnumber The amount of tracks to skip, e.g 5 would play the 5th song.