Player
Wrapper object around Lavalink
Extends
Constructors
new Player()
new Player(guildId: string, node: Node): PlayerParameters
| Parameter | Type |
|---|---|
guildId | string |
node | Node |
Returns
Overrides
TypedEventEmitter<PlayerEvents>.constructor
Defined in
shoukaku/src/guild/Player.ts:204
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(): UpdatePlayerInfoReturns
Defined in
shoukaku/src/guild/Player.ts:216
Methods
clearFilters()
clearFilters(): Promise<void>Clear all filters applied to the currently playing track
Returns
Promise<void>
Defined in
shoukaku/src/guild/Player.ts:405
destroy()
destroy(): Promise<void>Destroys the player in remote lavalink side
Returns
Promise<void>
Defined in
shoukaku/src/guild/Player.ts:271
emit()
emit<K>(eventName: K, ...args: PlayerEvents[Extract<K, string>]): booleanSynchronously 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 listenerType Parameters
| Type Parameter |
|---|
K extends symbol | keyof PlayerEvents |
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:242
off()
off<K>(eventName: K, listener: (...args: PlayerEvents[Extract<K, string>]) => void): thisAlias for emitter.removeListener().
Type Parameters
| Type Parameter |
|---|
K extends symbol | keyof PlayerEvents |
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): thisAdds 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// aType Parameters
| Type Parameter |
|---|
K extends symbol | keyof PlayerEvents |
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): voidHandle player update data
Parameters
| Parameter | Type |
|---|---|
json | PlayerUpdate |
Returns
void
Defined in
shoukaku/src/guild/Player.ts:505
once()
once<K>(eventName: K, listener: (...args: PlayerEvents[Extract<K, string>]) => void): thisAdds 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// aType Parameters
| Type Parameter |
|---|
K extends symbol | keyof PlayerEvents |
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 |
|---|---|---|
playerOptions | PlayOptions | undefined |
noReplace | boolean | false |
Returns
Promise<void>
Defined in
shoukaku/src/guild/Player.ts:278
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:425
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:301
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:382
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:374
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:325
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:317
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:398
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:309
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:333
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:390
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:293
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:365
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:341
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:349
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:357
stopTrack()
stopTrack(): Promise<void>Stop the currently playing track
Returns
Promise<void>
Defined in
shoukaku/src/guild/Player.ts:285
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>