Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Manager

The class that handles everything to do with Lavalink. it is the hub of the library basically

Hierarchy

  • EventEmitter
    • Manager

Index

Constructors

constructor

Properties

nodes

nodes: Map<string, LavalinkNode> = new Map<string, LavalinkNode>()

A Map of Lavalink Nodes

players

players: Map<string, Player> = new Map<string, Player>()

A Map of all the players

Optional send

send: undefined | ((packet: DiscordPacket) => unknown)

The send function needs for the library to function

shards

shards: number = 1

The amount of shards the bot has, by default its 1

user

user: string

The user id of the bot this Manager is managing

voiceServers

voiceServers: Map<string, VoiceServerUpdate> = new Map<string, VoiceServerUpdate>()

A Map of all the VOICE_SERVER_UPDATE States

voiceStates

voiceStates: Map<string, VoiceStateUpdate> = new Map<string, VoiceStateUpdate>()

A Map of all the VOICE_STATE_UPDATE States

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

idealNodes

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

  • connect(): Promise<Array<WebSocket | boolean>>

createNode

disconnect

  • disconnect(): Promise<boolean[]>
  • Disconnects everything, basically destorying the manager. Stops all players, leaves all voice channels then disconnects all LavalinkNodes

    Returns Promise<boolean[]>

emit

eventNames

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

getMaxListeners

  • getMaxListeners(): number
  • Returns number

join

leave

  • leave(guild: string): Promise<boolean>
  • Leaves the specified voice channel

    Parameters

    • guild: string

      The guild you want the bot to leave the voice channel of

    Returns Promise<boolean>

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: "ready", listener: (node: LavalinkNode) => void): this
  • off(event: "raw", listener: (message: unknown, node: LavalinkNode) => void): this
  • off(event: "error", listener: (error: unknown, node: LavalinkNode) => void): this
  • off(event: "disconnect", listener: (eventData: WebsocketCloseEvent, node: LavalinkNode) => void): this
  • off(event: "reconnecting", listener: (node: LavalinkNode) => void): this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • on(event: "ready", listener: (node: LavalinkNode) => void): this
  • on(event: "raw", listener: (message: unknown, node: LavalinkNode) => void): this
  • on(event: "error", listener: (error: unknown, node: LavalinkNode) => void): this
  • on(event: "disconnect", listener: (eventData: WebsocketCloseEvent, node: LavalinkNode) => void): this
  • on(event: "reconnecting", listener: (node: LavalinkNode) => void): this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • once(event: "ready", listener: (node: LavalinkNode) => void): this
  • once(event: "raw", listener: (message: unknown, node: LavalinkNode) => void): this
  • once(event: "error", listener: (error: unknown, node: LavalinkNode) => void): this
  • once(event: "disconnect", listener: (eventData: WebsocketCloseEvent, node: LavalinkNode) => void): this
  • once(event: "reconnecting", listener: (node: LavalinkNode) => void): this

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

removeNode

  • removeNode(id: string): boolean
  • Disconnects and Deletes the specified node

    Parameters

    • id: string

      The id of the node you want to remove

    Returns boolean

sendWS

  • sendWS(guild: string, channel: string | null, __namedParameters?: { selfdeaf: boolean; selfmute: boolean }): any
  • Just a utility method to easily send OPCode 4 websocket events to discord

    Parameters

    • guild: string

      The guild is

    • channel: string | null

      Voice channel id, or null to leave a voice channel

    • Default value __namedParameters: { selfdeaf: boolean; selfmute: boolean } = {}
      • selfdeaf: boolean
      • selfmute: boolean

    Returns any

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

switch

  • Switch a player from one node to another, this is to implement fallback

    Parameters

    • player: Player

      The player you want to switch nodes with

    • node: LavalinkNode

      The node you want to switch to

    Returns Promise<Player>

voiceServerUpdate

voiceStateUpdate

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[]>

Generated using TypeDoc