Skip to main content

Overview

The GuildQueuePlayerNode class manages all playback operations for a guild queue, including playing, pausing, seeking, volume control, and track manipulation. It is accessible via queue.node.

Constructor

new GuildQueuePlayerNode<Meta = any>(queue: GuildQueue<Meta>)
queue
GuildQueue<Meta>
required
The guild queue instance that owns this player node

Properties

queue
GuildQueue<Meta>
The guild queue instance associated with this player node
tasksQueue
AsyncQueue
Internal async queue for managing sequential tasks
streamTime
number
The stream time for the current playback session in milliseconds
playbackTime
number
Current playback duration with history included in milliseconds
estimatedPlaybackTime
number
Estimated progress of the player adjusted for filters in milliseconds
estimatedDuration
number
Estimated total duration of the current track adjusted for filters in milliseconds
totalDuration
number
Total duration of the current audio track in milliseconds
volume
number
Current volume level (0-100)

Playback State Methods

isIdle()

Checks if the player is currently in idle mode.
node.isIdle(): boolean
returns
boolean
true if the player is idle, false otherwise

isBuffering()

Checks if the player is currently buffering the track.
node.isBuffering(): boolean
returns
boolean
true if the player is buffering, false otherwise

isPlaying()

Checks if the player is currently playing a track.
node.isPlaying(): boolean
returns
boolean
true if the player is playing, false otherwise

isPaused()

Checks if the player is currently paused.
node.isPaused(): boolean
returns
boolean
true if the player is paused, false otherwise

Playback Control Methods

play()

Plays the given track or the next track in the queue.
async play(res?: Track | null, options?: ResourcePlayOptions): Promise<void>
res
Track | null
The track to play. If not provided, plays the next track from the queue
options
ResourcePlayOptions
Play options
Example:
// Play next track in queue
await queue.node.play();

// Play a specific track immediately
await queue.node.play(track, { queue: false });

// Play from 30 seconds
await queue.node.play(track, { seek: 30000 });

pause()

Pauses the playback.
node.pause(): boolean
returns
boolean
true if paused successfully, false otherwise
Example:
if (queue.node.pause()) {
  await interaction.reply('Paused the player!');
}

resume()

Resumes the playback.
node.resume(): boolean
returns
boolean
true if resumed successfully, false otherwise
Example:
if (queue.node.resume()) {
  await interaction.reply('Resumed the player!');
}

setPaused()

Sets the paused state.
node.setPaused(state: boolean): boolean
state
boolean
required
true to pause, false to resume
returns
boolean
true if state changed successfully, false otherwise

skip()

Skips the current track.
node.skip(options?: SkipOptions): boolean
options
SkipOptions
Skip options
returns
boolean
true if skipped successfully, false otherwise
Example:
if (queue.node.skip()) {
  await interaction.reply('Skipped to next track!');
}

stop()

Stops the playback and clears the queue.
node.stop(force?: boolean): boolean
force
boolean
default:"false"
If true, forcefully stops playback and destroys the dispatcher
returns
boolean
true if stopped successfully, false otherwise
Example:
queue.node.stop();
await interaction.reply('Stopped playback and cleared the queue!');

seek()

Seeks to a specific position in the current track.
async seek(duration: number): Promise<boolean>
duration
number
required
The position to seek to in milliseconds
returns
Promise<boolean>
true if seek was successful, false otherwise
Example:
// Seek to 1 minute 30 seconds
const seeked = await queue.node.seek(90000);
if (seeked) {
  await interaction.reply('Seeked to 1:30!');
}

Volume Control Methods

setVolume()

Sets the volume level.
node.setVolume(vol: number): boolean
vol
number
required
Volume level (0-100+). Values over 100 are allowed but may cause distortion
returns
boolean
true if volume changed successfully, false otherwise
Example:
queue.node.setVolume(50);
await interaction.reply('Volume set to 50%');

setBitrate()

Sets the bitrate for audio encoding.
node.setBitrate(rate: number | 'auto'): void
rate
number | 'auto'
required
Bitrate in bits per second, or 'auto' to use the voice channel’s bitrate
Example:
// Use channel's bitrate
queue.node.setBitrate('auto');

// Set to 128kbps
queue.node.setBitrate(128000);

Track Management Methods

insert()

Inserts a track at a specific position in the queue.
node.insert(track: Track, index?: number): void
track
Track
required
The track to insert
index
number
default:"0"
The position to insert at (0 = next track)
Example:
// Insert track as next
queue.node.insert(track);

// Insert track at position 5
queue.node.insert(track, 5);

remove()

Removes a track from the queue.
node.remove(track: TrackResolvable, emitEvent?: boolean): Track | null
track
TrackResolvable
required
The track to remove (can be Track instance, track ID string, or index number)
emitEvent
boolean
default:"true"
Whether to emit the audioTrackRemove event
returns
Track | null
The removed track, or null if not found
Example:
// Remove by index
const removed = queue.node.remove(0);

// Remove by track ID
queue.node.remove(track.id);

// Remove by track instance
queue.node.remove(track);

jump()

Jumps to a specific track without removing other tracks.
node.jump(track: TrackResolvable): boolean
track
TrackResolvable
required
The track to jump to
returns
boolean
true if jumped successfully, false if track not found
Example:
// Jump to track at index 5
if (queue.node.jump(5)) {
  await interaction.reply('Jumped to track 6!');
}

skipTo()

Skips to a specific track, removing all tracks before it.
node.skipTo(track: TrackResolvable): boolean
track
TrackResolvable
required
The track to skip to
returns
boolean
true if skipped successfully, false if track not found
Example:
// Skip to track at index 5, removing tracks 0-4
if (queue.node.skipTo(5)) {
  await interaction.reply('Skipped to track 6!');
}

move()

Moves a track from one position to another.
node.move(from: TrackResolvable, to: number): void
from
TrackResolvable
required
The track to move
to
number
required
The destination position
Example:
// Move track from position 5 to position 0 (next)
queue.node.move(5, 0);

copy()

Copies a track to another position in the queue.
node.copy(from: TrackResolvable, to: number): void
from
TrackResolvable
required
The track to copy
to
number
required
The position to copy to
Example:
// Copy track from position 0 to position 5
queue.node.copy(0, 5);

swap()

Swaps two tracks in the queue.
node.swap(first: TrackResolvable, second: TrackResolvable): void
first
TrackResolvable
required
The first track to swap
second
TrackResolvable
required
The second track to swap
Example:
// Swap tracks at positions 0 and 5
queue.node.swap(0, 5);

getTrackPosition()

Gets the position of a track in the queue.
node.getTrackPosition(track: TrackResolvable): number
track
TrackResolvable
required
The track to find
returns
number
The index of the track, or -1 if not found
Example:
const position = queue.node.getTrackPosition(track);
console.log(`Track is at position ${position + 1}`);

Progress Methods

getTimestamp()

Gets the current playback timestamp information.
node.getTimestamp(ignoreFilters?: boolean): PlayerTimestamp | null
ignoreFilters
boolean
default:"false"
If true, returns raw timestamps without filter adjustments
returns
PlayerTimestamp | null
Timestamp object or null if no track is playing
Example:
const timestamp = queue.node.getTimestamp();
if (timestamp) {
  console.log(`${timestamp.current.label} / ${timestamp.total.label}`);
  console.log(`Progress: ${timestamp.progress}%`);
}

createProgressBar()

Creates a visual progress bar for the current track.
node.createProgressBar(options?: PlayerProgressbarOptions): string | null
options
PlayerProgressbarOptions
Progress bar customization options
returns
string | null
The formatted progress bar string, or null if no track is playing
Example:
const progressBar = queue.node.createProgressBar();
console.log(progressBar);
// Output: 1:30 ┃ ▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬ ┃ 3:45

// Custom progress bar
const customBar = queue.node.createProgressBar({
  length: 20,
  indicator: '🎵',
  leftChar: '━',
  rightChar: '─'
});

resetProgress()

Resets the progress history.
node.resetProgress(): void

setProgress()

Manually sets the player progress.
node.setProgress(progress: number): void
progress
number
required
The progress value in milliseconds

getDurationMultiplier()

Gets the duration multiplier based on active filters.
node.getDurationMultiplier(): number
returns
number
The duration multiplier value

Advanced Methods

requestSeek()

Requests the source to seek (for seekable streams).
async requestSeek(data: SeekEvent): Promise<boolean>
data
SeekEvent
required
Seek event data containing position information
returns
Promise<boolean>
true if seek request was successful, false otherwise

TrackResolvable

type TrackResolvable = Track | string | number
Can be:
  • A Track instance
  • A track ID string
  • A queue index number

TrackSkipReason

enum TrackSkipReason {
  Manual = 'manual',
  Jump = 'jump',
  SkipTo = 'skipTo',
  HistoryNext = 'historyNext',
  NoStream = 'noStream',
  SEEK_OVER_THRESHOLD = 'seekOverThreshold'
}

Build docs developers (and LLMs) love