Skip to content

Player

Wrapper object around Lavalink

Extends

Constructors

new Player()

new Player(guildId: string, node: Node): Player

Parameters

ParameterType
guildIdstring
nodeNode

Returns

Player

Overrides

TypedEventEmitter<PlayerEvents>.constructor

Defined in

shoukaku/src/guild/Player.ts:207

Properties

filters

filters: FilterOptions;

Filters on current track

Defined in

shoukaku/src/guild/Player.ts:205


guildId

readonly guildId: string;

GuildId of this player

Defined in

shoukaku/src/guild/Player.ts:177


node

node: Node;

Lavalink node this player is connected to

Defined in

shoukaku/src/guild/Player.ts:181


paused

paused: boolean;

Pause status in current player

Defined in

shoukaku/src/guild/Player.ts:193


ping

ping: number;

Ping represents the number of milliseconds between heartbeat and ack. Could be -1 if not connected

Defined in

shoukaku/src/guild/Player.ts:197


position

position: number;

Position in ms of current track

Defined in

shoukaku/src/guild/Player.ts:201


track

track: null | string;

Base64 encoded data of the current track

Defined in

shoukaku/src/guild/Player.ts:185


volume

volume: number;

Global volume of the player

Defined in

shoukaku/src/guild/Player.ts:189

Accessors

data

get data(): UpdatePlayerInfo

Returns

UpdatePlayerInfo

Defined in

shoukaku/src/guild/Player.ts:219

Methods

clearFilters()

clearFilters(): Promise<void>

Clear all filters applied to the currently playing track

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:408


destroy()

destroy(): Promise<void>

Destroys the player in remote lavalink side

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:274


emit()

emit<K>(eventName: K, ...args: PlayerEvents[Extract<K, string>]): boolean

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

Returns true if the event had listeners, false otherwise.

import { EventEmitter } from 'node:events';
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener

Type Parameters

Type Parameter
K extends symbol | keyof PlayerEvents

Parameters

ParameterType
eventNameK
argsPlayerEvents[Extract<K, string>]

Returns

boolean

Inherited from

TypedEventEmitter.emit

Since

v0.1.26

Defined in

shoukaku/src/Utils.ts:21


move()

move(name?: string): Promise<boolean>

Move player to another node

Parameters

ParameterTypeDescription
name?stringName of node to move to, or the default ideal node

Returns

Promise<boolean>

true if the player was moved, false if not

Defined in

shoukaku/src/guild/Player.ts:245


off()

off<K>(eventName: K, listener: (...args: PlayerEvents[Extract<K, string>]) => void): this

Alias for emitter.removeListener().

Type Parameters

Type Parameter
K extends symbol | keyof PlayerEvents

Parameters

ParameterType
eventNameK
listener(…args: PlayerEvents[Extract<K, string>]) => void

Returns

this

Inherited from

TypedEventEmitter.off

Since

v10.0.0

Defined in

shoukaku/src/Utils.ts:17


on()

on<K>(eventName: K, listener: (...args: PlayerEvents[Extract<K, string>]) => void): this

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

server.on('connection', (stream) => {
console.log('someone connected!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a

Type Parameters

Type Parameter
K extends symbol | keyof PlayerEvents

Parameters

ParameterTypeDescription
eventNameKThe name of the event.
listener(…args: PlayerEvents[Extract<K, string>]) => voidThe callback function

Returns

this

Inherited from

TypedEventEmitter.on

Since

v0.1.101

Defined in

shoukaku/src/Utils.ts:9


onPlayerUpdate()

onPlayerUpdate(json: PlayerUpdate): void

Handle player update data

Parameters

ParameterType
jsonPlayerUpdate

Returns

void

Defined in

shoukaku/src/guild/Player.ts:508


once()

once<K>(eventName: K, listener: (...args: PlayerEvents[Extract<K, string>]) => void): this

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

server.once('connection', (stream) => {
console.log('Ah, we have our first user!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.once('foo', () => console.log('a'));
myEE.prependOnceListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a

Type Parameters

Type Parameter
K extends symbol | keyof PlayerEvents

Parameters

ParameterTypeDescription
eventNameKThe name of the event.
listener(…args: PlayerEvents[Extract<K, string>]) => voidThe callback function

Returns

this

Inherited from

TypedEventEmitter.once

Since

v0.3.0

Defined in

shoukaku/src/Utils.ts:13


playTrack()

playTrack(playerOptions: PlayOptions, noReplace: boolean): Promise<void>

Play a new track

Parameters

ParameterTypeDefault value
playerOptionsPlayOptionsundefined
noReplacebooleanfalse

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:281


resume()

resume(options: ResumeOptions, noReplace: boolean): Promise<void>

Resumes the current track

Parameters

ParameterTypeDefault valueDescription
optionsResumeOptions{}An object that conforms to ResumeOptions that specify behavior on resuming
noReplacebooleanfalseSet it to true if you don’t want to replace the currently playing track

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:428


seekTo()

seekTo(position: number): Promise<void>

Seek to a specific time in the currently playing track

Parameters

ParameterTypeDescription
positionnumberPosition to seek to in milliseconds

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:304


setChannelMix()

setChannelMix(channelMix?: ChannelMixSettings): Promise<void>

Change the channel mix settings applied to the currently playing track

Parameters

ParameterTypeDescription
channelMix?ChannelMixSettingsAn object that conforms to ChannelMixSettings that defines how much the left and right channels affect each other (setting all factors to 0.5 causes both channels to get the same audio)

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:385


setDistortion()

setDistortion(distortion?: DistortionSettings): Promise<void>

Change the distortion settings applied to the currently playing track

Parameters

ParameterTypeDescription
distortion?DistortionSettingsAn object that conforms to DistortionSettings that defines distortions in the audio

Returns

Promise<void>

The current player instance

Defined in

shoukaku/src/guild/Player.ts:377


setEqualizer()

setEqualizer(equalizer: Band[]): Promise<void>

Change the equalizer settings applied to the currently playing track

Parameters

ParameterTypeDescription
equalizerBand[]An array of objects that conforms to the Bands type that define volumes at different frequencies

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:328


setFilterVolume()

setFilterVolume(volume: number): Promise<void>

Sets the filter volume of the player

Parameters

ParameterTypeDescription
volumenumberTarget volume 0.0-5.0

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:320


setFilters()

setFilters(filters: FilterOptions): Promise<void>

Change the all filter settings applied to the currently playing track

Parameters

ParameterTypeDescription
filtersFilterOptionsAn object that conforms to FilterOptions that defines all filters to apply/modify

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:401


setGlobalVolume()

setGlobalVolume(volume: number): Promise<void>

Sets the global volume of the player

Parameters

ParameterTypeDescription
volumenumberTarget volume 0-1000

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:312


setKaraoke()

setKaraoke(karaoke?: KaraokeSettings): Promise<void>

Change the karaoke settings applied to the currently playing track

Parameters

ParameterTypeDescription
karaoke?KaraokeSettingsAn object that conforms to the KaraokeSettings type that defines a range of frequencies to mute

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:336


setLowPass()

setLowPass(lowPass?: LowPassSettings): Promise<void>

Change the low pass settings applied to the currently playing track

Parameters

ParameterTypeDescription
lowPass?LowPassSettingsAn object that conforms to LowPassSettings that defines the amount of suppression on higher frequencies

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:393


setPaused()

setPaused(paused: boolean): Promise<void>

Pause or unpause the currently playing track

Parameters

ParameterTypeDefault valueDescription
pausedbooleantrueBoolean value to specify whether to pause or unpause the current bot user

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:296


setRotation()

setRotation(rotation?: RotationSettings): Promise<void>

Change the rotation settings applied to the currently playing track

Parameters

ParameterTypeDescription
rotation?RotationSettingsAn object that conforms to the RotationSettings type that defines the frequency of audio rotating round the listener

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:368


setTimescale()

setTimescale(timescale?: TimescaleSettings): Promise<void>

Change the timescale settings applied to the currently playing track

Parameters

ParameterTypeDescription
timescale?TimescaleSettingsAn object that conforms to the TimescaleSettings type that defines the time signature to play the audio at

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:344


setTremolo()

setTremolo(tremolo?: FreqSettings): Promise<void>

Change the tremolo settings applied to the currently playing track

Parameters

ParameterTypeDescription
tremolo?FreqSettingsAn object that conforms to the FreqSettings type that defines an oscillation in volume

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:352


setVibrato()

setVibrato(vibrato?: FreqSettings): Promise<void>

Change the vibrato settings applied to the currently playing track

Parameters

ParameterTypeDescription
vibrato?FreqSettingsAn object that conforms to the FreqSettings type that defines an oscillation in pitch

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:360


stopTrack()

stopTrack(): Promise<void>

Stop the currently playing track

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:288


update()

update(playerOptions: UpdatePlayerOptions, noReplace: boolean): Promise<void>

If you want to update the whole player yourself, sends raw update player info to lavalink

Parameters

ParameterTypeDefault valueDescription
playerOptionsUpdatePlayerOptionsundefinedOptions to update the player data
noReplacebooleanfalseSet it to true if you don’t want to replace the currently playing track

Returns

Promise<void>

Defined in

shoukaku/src/guild/Player.ts:450