Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseNode

Hierarchy

Index

Constructors

Properties

_expectingConnection: Set<string> = ...
connection: null | Connection<BaseNode> = null
http: null | Http = null
password: string
send: NodeSend
shardCount?: number
userID: string
voiceServers: Map<string, GatewayVoiceServerUpdateDispatchData> = ...
voiceStates: Map<string, GatewayVoiceState> = ...

Accessors

  • get connected(): boolean
  • Whether or not the node is connected to the websocket.

    Returns boolean

Methods

  • _tryConnection(guildID: string): Promise<boolean>
  • connect(): Promise<void>
  • decode(track: string): Promise<TrackInfo>
  • decode(tracks: string[]): Promise<Track[]>
  • Decodes a track.

    example
    const identifier = 'QAAAjQIAJVJpY2sgQXN0bGV5IC0gTmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXAADlJpY2tBc3RsZXlWRVZPAAAAAAADPCAAC2RRdzR3OVdnWGNRAAEAK2h0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9ZFF3NHc5V2dYY1EAB3lvdXR1YmUAAAAAAAAAAA==';

    const track = await http.decode(identifier);
    console.log(track);
    // Logs: {
    // "identifier": "dQw4w9WgXcQ",
    // "isSeekable": true,
    // "author": "RickAstleyVEVO",
    // "length": 212000,
    // "isStream": false,
    // "position": 0,
    // "title": "Rick Astley - Never Gonna Give You Up",
    // "uri": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    // }

    Parameters

    • track: string

      The track to be decoded.

    Returns Promise<TrackInfo>

  • Decodes multiple tracks.

    note

    This returns an array of Tracks, not a TrackInfo.

    Parameters

    • tracks: string[]

      The tracks to be decoded.

    Returns Promise<Track[]>

  • destroy(code?: number, data?: string): Promise<void>
  • Parameters

    • Optional code: number
    • Optional data: string

    Returns Promise<void>

  • disconnect(code?: number, data?: string): Promise<boolean>
  • Parameters

    • Optional code: number
    • Optional data: string

    Returns Promise<boolean>

  • Loads a song.

    example
    // Load from URL:

    const result = await node.load('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
    console.log(result);
    // {
    // "loadType": "TRACK_LOADED",
    // "playlistInfo": {},
    // "tracks": [
    // {
    // "track": "QAAAjQIAJVJpY2sgQXN0bGV5IC0gTmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXAADlJpY2tBc3RsZXlWRVZPAAAAAAADPCAAC2RRdzR3OVdnWGNRAAEAK2h0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9ZFF3NHc5V2dYY1EAB3lvdXR1YmUAAAAAAAAAAA==",
    // "info": {
    // "identifier": "dQw4w9WgXcQ",
    // "isSeekable": true,
    // "author": "RickAstleyVEVO",
    // "length": 212000,
    // "isStream": false,
    // "position": 0,
    // "title": "Rick Astley - Never Gonna Give You Up",
    // "uri": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    // }
    // }
    // ]
    // }
    example
    // Load from YouTube search:

    const result = await node.load('ytsearch: Never Gonna Give You Up');
    console.log(result);
    // {
    // "loadType": "SEARCH_RESULT",
    // "playlistInfo": {},
    // "tracks": [
    // {
    // "track": "...",
    // "info": {
    // "identifier": "dQw4w9WgXcQ",
    // "isSeekable": true,
    // "author": "RickAstleyVEVO",
    // "length": 212000,
    // "isStream": false,
    // "position": 0,
    // "title": "Rick Astley - Never Gonna Give You Up",
    // "uri": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    // }
    // },
    // ...
    // ]
    // }

    Parameters

    • identifier: string

      The track to be loaded.

    Returns Promise<TrackResponse>

  • voiceServerUpdate(packet: GatewayVoiceServerUpdateDispatchData): Promise<boolean>
  • Parameters

    • packet: GatewayVoiceServerUpdateDispatchData

    Returns Promise<boolean>

  • voiceStateUpdate(packet: GatewayVoiceState): Promise<boolean>

Generated using TypeDoc