Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Player

The Player class, this handles everything to do with the guild sides of things, like playing, stoping, pausing, resuming etc

Hierarchy

  • EventEmitter
    • Player

Index

Constructors

constructor

  • The constructor of the player

    Parameters

    • node: LavalinkNode

      The Lavalink of the player

    • id: string

      the id of the player, aka the guild id

    Returns Player

Properties

id

id: string

the id of the player, aka the guild id

node

The Lavalink of the player

paused

paused: boolean = false

Whether or not the song that is playing is paused or not

playing

playing: boolean = false

Whether or not the player is actually playing anything

timestamp

timestamp: number | null = null

When the track started playing

track

track: string | null = null

The current track in Lavalink's base64 string form

voiceUpdateState

voiceUpdateState: PlayerUpdateVoiceState | null = null

The voiceUpdateState of the player, used for swtiching nodes

Static Readonly captureRejectionSymbol

captureRejectionSymbol: keyof symbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: keyof symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

manager

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

connect

  • Sends voiceUpdate information to lavalink so it can connect to discords voice servers properly

    Parameters

    Returns Promise<boolean>

destroy

  • destroy(): Promise<boolean>
  • Sends a destroy signal to lavalink, basically just a cleanup op for lavalink to clean its shit up

    Returns Promise<boolean>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • emit(event: "event", data: LavalinkEvent): boolean
  • emit(event: "start", data: LavalinkEvent): boolean
  • emit(event: "end", data: LavalinkEvent): boolean
  • emit(event: "pause", pause: boolean): boolean
  • emit(event: "seek", position: number): boolean
  • emit(event: "error", error: LavalinkEvent): boolean
  • emit(event: "warn", warning: string): boolean
  • emit(event: "volume", volume: number): boolean
  • emit(event: "playerUpdate", data: { state: LavalinkPlayerState }): boolean
  • emit(event: "filters", data: PlayerFilterOptions): boolean

equalizer

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

filters

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • off(event: "event", listener: (data: LavalinkEvent) => void): this
  • off(event: "start", listener: (data: LavalinkEvent) => void): this
  • off(event: "end", listener: (data: LavalinkEvent) => void): this
  • off(event: "pause", listener: (pause: boolean) => void): this
  • off(event: "seek", listener: (position: number) => void): this
  • off(event: "error", listener: (error: LavalinkEvent) => void): this
  • off(event: "warn", listener: (warning: string) => void): this
  • off(event: "volume", listener: (volume: number) => void): this
  • off(event: "playerUpdate", listener: (data: { state: LavalinkPlayerState }) => void): this
  • off(event: "filters", listener: (data: PlayerFilterOptions) => void): this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • on(event: "event", listener: (data: LavalinkEvent) => void): this
  • on(event: "start", listener: (data: LavalinkEvent) => void): this
  • on(event: "end", listener: (data: LavalinkEvent) => void): this
  • on(event: "pause", listener: (pause: boolean) => void): this
  • on(event: "seek", listener: (position: number) => void): this
  • on(event: "error", listener: (error: LavalinkEvent) => void): this
  • on(event: "warn", listener: (warning: string) => void): this
  • on(event: "volume", listener: (volume: number) => void): this
  • on(event: "playerUpdate", listener: (data: { state: LavalinkPlayerState }) => void): this
  • on(event: "filters", listener: (data: PlayerFilterOptions) => void): this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • once(event: "event", listener: (data: LavalinkEvent) => void): this
  • once(event: "start", listener: (data: LavalinkEvent) => void): this
  • once(event: "end", listener: (data: LavalinkEvent) => void): this
  • once(event: "pause", listener: (pause: boolean) => void): this
  • once(event: "seek", listener: (position: number) => void): this
  • once(event: "error", listener: (error: LavalinkEvent) => void): this
  • once(event: "warn", listener: (warning: string) => void): this
  • once(event: "volume", listener: (volume: number) => void): this
  • once(event: "playerUpdate", listener: (data: { state: LavalinkPlayerState }) => void): this
  • once(event: "filters", listener: (data: PlayerFilterOptions) => void): this

pause

  • pause(pause: boolean): Promise<boolean>
  • Pauses/Resumes the song depending on what is specified

    Parameters

    • pause: boolean

      Whether or not to pause whats currently playing

    Returns Promise<boolean>

play

  • Plays the specified song using the base64 string from lavalink

    Parameters

    • track: string

      The base64 string of the song that you want to play

    • Default value options: PlayerPlayOptions = {}

      Play options

    Returns Promise<boolean>

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

resume

  • resume(): Promise<boolean>

seek

  • seek(position: number): Promise<boolean>
  • Seeks the current song to a certain position

    Parameters

    • position: number

      Seeks the song to the position specified in milliseconds, use the duration of the song from lavalink to get the duration

    Returns Promise<boolean>

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

stop

  • stop(): Promise<boolean>
  • Stops the music, depending on how the end event is handled this will either stop

    Returns Promise<boolean>

switchChannel

  • switchChannel(channel: string, options?: JoinOptions): any
  • Use this to switch channels

    Parameters

    • channel: string

      The channel id of the channel you want to switch to

    • Default value options: JoinOptions = {}

      selfMute and selfDeaf options

    Returns any

volume

  • volume(volume: number): Promise<boolean>
  • Changes the volume, only for the current song

    Parameters

    • volume: number

      The volume as a float from 0.0 to 10.0. 1.0 is default.

    Returns Promise<boolean>

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol

    Returns Promise<any[]>

Object literals

state

state: object

The PlayerState of this Player

filters

filters: {}

Type declaration

Generated using TypeDoc