Player

Player

The player, handles joining, playback and queueing of tracks. It shouldn't be necessary to create this object as getPlayer will create it for you.

Constructor

new Player(guildId)

Parameters:
Name Type Description
guildId GuildID
Source:

Methods

addTrack(track) → {Number}

Add a track to the queue
Parameters:
Name Type Description
track Track The track to be added to the queue
Source:
Returns:
The queue length
Type
Number

(async) addTrackNice(guildId, track, dontStartPlayeropt, createopt) → {Object}

Adds the tracks to the queue, can be configured to start or create the player
Parameters:
Name Type Attributes Default Description
guildId GuildID
track Track | Array.<Track> The track(s) to add
dontStartPlayer Boolean <optional>
false Set to true if the player should start playing if nothing else is
create Boolean <optional>
true Set to false if the player shouldn't be created
Source:
Returns:
Info about added
Type
Object

getQueue(startopt, stopopt, infoopt) → {object}

Gets the current queue
Parameters:
Name Type Attributes Default Description
start Number <optional>
0 Index to start from
stop Number <optional>
-1 Index to end on
info Boolean <optional>
true Include the whole Track object, or just the info
Source:
Returns:
The queue object
Type
object

(async) join(voiceChannel)

Join a voice channel
Parameters:
Name Type Description
voiceChannel VoiceChannel discord.js voiceChannel object to join
Source:

(async) joinNice(voiceChannel, forceJoinopt)

Join a voice channel with extra options
Parameters:
Name Type Attributes Default Description
voiceChannel VoiceChannel
forceJoin Boolean <optional>
false If it should try to connect, even when connected
Source:

(async) pause() → {Promise.<boolean>}

Pauses the playback
Source:
Returns:
True if it could pause
Type
Promise.<boolean>

removeFromQueue(uid)

Removes a track from the queue using uid's
Parameters:
Name Type Description
uid String a tracks unique id
Source:

setRepeat(modeopt)

Set the repeat mode
Parameters:
Name Type Attributes Default Description
mode String <optional>
"none" "none|all|single"
Source:

shuffleQueue()

Shuffles the queue
Source:

skipCurrentTrack()

Skip the currently playing track.
Source:

(async) startNextTrack(shiftopt, preloadNextopt) → {Promise.<?Track>}

Starts the next track
Parameters:
Name Type Attributes Default Description
shift Boolean <optional>
false If the player should play the next element in the queue, or restart the current. Ignored if player.repeat is "single"
preloadNext Boolean <optional>
true If the player should preload the next track for quicker playback.
Source:
Returns:
The track that started playing.
Type
Promise.<?Track>

(async) unpause() → {Promise.<boolean>}

Unpauses the playback
Source:
Returns:
True if it could unpause
Type
Promise.<boolean>

Events

joinedVoiceChannel

Player joined a voice channel
Type:
  • object
Properties:
Name Type Description
player Player
Source:

playerCreated

Player created event.
Type:
  • object
Properties:
Name Type Description
player Player
Source:

playerDestroyed

Player was destroyed
Type:
  • Object
Properties:
Name Type Description
guildId GuildID
Source:

playingTrack

Player started playing a track.
Type:
  • object
Properties:
Name Type Description
player Player
track Track The track that was started
Source:

skippedTrack

Player skipped track
Type:
  • object
Properties:
Name Type Description
player Player
Source:

trackEnded

Player started playing a track.
Type:
  • object
Properties:
Name Type Description
player Player
track Track The track that was started
Source: