Player
This content is for the 4.1.0 version. Switch to the latest version for up-to-date documentation.
Wrapper object around Lavalink
Extends
Constructors
new Player()
new Player(guildId: string, node: Node): Player
Parameters
Parameter | Type | Description |
---|---|---|
guildId | string | - |
node | Node | An instance of Node (Lavalink API wrapper) |
Returns
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:202
guildId
readonly guildId: string;
GuildId of this player
Defined in
shoukaku/src/guild/Player.ts:174
node
node: Node;
Lavalink node this player is connected to
Defined in
shoukaku/src/guild/Player.ts:178
paused
paused: boolean;
Pause status in current player
Defined in
shoukaku/src/guild/Player.ts:190
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:194
position
position: number;
Position in ms of current track
Defined in
shoukaku/src/guild/Player.ts:198
track
track: null | string;
Base64 encoded data of the current track
Defined in
shoukaku/src/guild/Player.ts:182
volume
volume: number;
Global volume of the player
Defined in
shoukaku/src/guild/Player.ts:186
Accessors
data
get data(): UpdatePlayerInfo
Returns
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:410
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 listenermyEmitter.on('event', function firstListener() { console.log('Helloooo! first listener');});// Second listenermyEmitter.on('event', function secondListener(arg1, arg2) { console.log(`event with parameters ${arg1}, ${arg2} in second listener`);});// Third listenermyEmitter.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 |
Parameters
Parameter | Type |
---|---|
eventName | K |
…args | PlayerEvents [Extract <K , string >] |
Returns
boolean
Inherited from
Since
v0.1.26
Defined in
move()
move(name?: string): Promise<boolean>
Move player to another node
Parameters
Parameter | Type | Description |
---|---|---|
name ? | string | Name 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 |
Parameters
Parameter | Type |
---|---|
eventName | K |
listener | (…args : PlayerEvents [Extract <K , string >]) => void |
Returns
this
Inherited from
Since
v10.0.0
Defined in
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 |
Parameters
Parameter | Type | Description |
---|---|---|
eventName | K | The name of the event. |
listener | (…args : PlayerEvents [Extract <K , string >]) => void | The callback function |
Returns
this
Inherited from
Since
v0.1.101
Defined in
onPlayerUpdate()
onPlayerUpdate(json: PlayerUpdate): void
Handle player update data
Parameters
Parameter | Type |
---|---|
json | PlayerUpdate |
Returns
void
Defined in
shoukaku/src/guild/Player.ts:511
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 |
Parameters
Parameter | Type | Description |
---|---|---|
eventName | K | The name of the event. |
listener | (…args : PlayerEvents [Extract <K , string >]) => void | The callback function |
Returns
this
Inherited from
Since
v0.3.0
Defined in
playTrack()
playTrack(playerOptions: PlayOptions, noReplace: boolean): Promise<void>
Play a new track
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
playerOptions | PlayOptions | undefined | - |
noReplace | boolean | false | Set it to true if you don’t want to replace the currently playing track |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:283
resume()
resume(options: ResumeOptions, noReplace: boolean): Promise<void>
Resumes the current track
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
options | ResumeOptions | {} | An object that conforms to ResumeOptions that specify behavior on resuming |
noReplace | boolean | false | Set it to true if you don’t want to replace the currently playing track |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:430
seekTo()
seekTo(position: number): Promise<void>
Seek to a specific time in the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
position | number | Position to seek to in milliseconds |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:306
setChannelMix()
setChannelMix(channelMix?: ChannelMixSettings): Promise<void>
Change the channel mix settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
channelMix ? | ChannelMixSettings | An 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:387
setDistortion()
setDistortion(distortion?: DistortionSettings): Promise<void>
Change the distortion settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
distortion ? | DistortionSettings | An 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:379
setEqualizer()
setEqualizer(equalizer: Band[]): Promise<void>
Change the equalizer settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
equalizer | Band [] | 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:330
setFilterVolume()
setFilterVolume(volume: number): Promise<void>
Sets the filter volume of the player
Parameters
Parameter | Type | Description |
---|---|---|
volume | number | Target volume 0.0-5.0 |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:322
setFilters()
setFilters(filters: FilterOptions): Promise<void>
Change the all filter settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
filters | FilterOptions | An object that conforms to FilterOptions that defines all filters to apply/modify |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:403
setGlobalVolume()
setGlobalVolume(volume: number): Promise<void>
Sets the global volume of the player
Parameters
Parameter | Type | Description |
---|---|---|
volume | number | Target volume 0-1000 |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:314
setKaraoke()
setKaraoke(karaoke?: KaraokeSettings): Promise<void>
Change the karaoke settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
karaoke ? | KaraokeSettings | An 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:338
setLowPass()
setLowPass(lowPass?: LowPassSettings): Promise<void>
Change the low pass settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
lowPass ? | LowPassSettings | An object that conforms to LowPassSettings that defines the amount of suppression on higher frequencies |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:395
setPaused()
setPaused(paused: boolean): Promise<void>
Pause or unpause the currently playing track
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
paused | boolean | true | Boolean value to specify whether to pause or unpause the current bot user |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:298
setRotation()
setRotation(rotation?: RotationSettings): Promise<void>
Change the rotation settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
rotation ? | RotationSettings | An 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:370
setTimescale()
setTimescale(timescale?: TimescaleSettings): Promise<void>
Change the timescale settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
timescale ? | TimescaleSettings | An 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:346
setTremolo()
setTremolo(tremolo?: FreqSettings): Promise<void>
Change the tremolo settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
tremolo ? | FreqSettings | An object that conforms to the FreqSettings type that defines an oscillation in volume |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:354
setVibrato()
setVibrato(vibrato?: FreqSettings): Promise<void>
Change the vibrato settings applied to the currently playing track
Parameters
Parameter | Type | Description |
---|---|---|
vibrato ? | FreqSettings | An object that conforms to the FreqSettings type that defines an oscillation in pitch |
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:362
stopTrack()
stopTrack(): Promise<void>
Stop the currently playing track
Returns
Promise
<void
>
Defined in
shoukaku/src/guild/Player.ts:290
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
Parameter | Type | Default value | Description |
---|---|---|---|
playerOptions | UpdatePlayerOptions | undefined | Options to update the player data |
noReplace | boolean | false | Set it to true if you don’t want to replace the currently playing track |
Returns
Promise
<void
>