Class Queue<Context>

Represents a music queue for a guild Manages tracks, playback state, and filters

Type Parameters

  • Context extends Record<string, unknown> = QueueContext

Constructors

Properties

context: Context = ...
voice: VoiceState
filters: FilterManager
player: Player<QueueContext, []>

Accessors

Methods

  • Sync queue state with Lavalink

    Parameters

    • target: "local" | "remote" = "local"

      "local" to pull from Lavalink, "remote" to push to Lavalink

    Returns Promise<void>

  • Search for tracks

    Parameters

    • query: string
    • prefix: string = ...

    Returns Promise<SearchResult>

  • Add tracks to the queue

    Parameters

    • source: Track<CommonUserData, CommonPluginInfo> | Track<CommonUserData, CommonPluginInfo>[] | Playlist<CommonPluginInfo>
    • Optional userData: JsonObject

    Returns this

  • Add related tracks (for autoplay)

    Parameters

    • Optional refTrack: Track<CommonUserData, CommonPluginInfo>

    Returns Promise<Track<CommonUserData, CommonPluginInfo>[]>

  • Remove tracks from the queue

    Parameters

    • index: number

    Returns undefined | Track<CommonUserData, CommonPluginInfo>

  • Parameters

    • indices: number[]

    Returns Track<CommonUserData, CommonPluginInfo>[]

  • Clear tracks from the queue

    Parameters

    • Optional type: "current" | "previous"

    Returns void

  • Jump to a specific track

    Parameters

    • index: number

    Returns Promise<Track<CommonUserData, CommonPluginInfo>>

  • Seek to a position

    Parameters

    • ms: number

    Returns Promise<number>

  • Play next track

    Returns Promise<null | Track<CommonUserData, CommonPluginInfo>>

  • Play previous track

    Returns Promise<null | Track<CommonUserData, CommonPluginInfo>>

  • Shuffle tracks

    Parameters

    • includePrevious: boolean = false

    Returns this

  • Set volume

    Parameters

    • volume: number

    Returns Promise<number>

  • Set autoplay

    Parameters

    • autoplay: boolean = false

    Returns boolean

  • Set repeat mode

    Parameters

    • repeatMode: RepeatMode = "none"

    Returns RepeatMode

  • Destroy the queue

    Parameters

    • Optional reason: string

    Returns Promise<void>

  • Move a track from one position to another

    Parameters

    • from: number

      Current position of the track

    • to: number

      New position for the track

    Returns null | Track<CommonUserData, CommonPluginInfo>

  • Splice tracks - remove and/or add tracks at a specific position

    Parameters

    • index: number

      Position to start

    • amount: number

      Number of tracks to remove

    • Optional tracks: Track<CommonUserData, CommonPluginInfo> | Track<CommonUserData, CommonPluginInfo>[]

      Tracks to add at the position

    Returns Track<CommonUserData, CommonPluginInfo>[]

  • Sort tracks by a property or custom function

    Parameters

    • sortBy: "title" | "author" | "duration" | ((a, b) => number)

      Property name or comparator function

    • order: "asc" | "desc" = "asc"

      Sort order (asc/desc)

    Returns this

  • Get a sorted copy without modifying the original queue

    Parameters

    • sortBy: "title" | "author" | "duration" | ((a, b) => number)
    • order: "asc" | "desc" = "asc"

    Returns Track<CommonUserData, CommonPluginInfo>[]

  • Filter tracks by predicate or criteria

    Parameters

    • predicate: {
          title?: string;
          author?: string;
          duration?: number | {
              min?: number;
              max?: number;
          };
          uri?: string;
          identifier?: string;
          sourceName?: string;
          isStream?: boolean;
          isSeekable?: boolean;
      } | ((track, index) => boolean)

    Returns {
        track: Track<CommonUserData, CommonPluginInfo>;
        index: number;
    }[]

  • Find a track by predicate or criteria

    Parameters

    • predicate: {
          title?: string;
          author?: string;
          duration?: number | {
              min?: number;
              max?: number;
          };
          uri?: string;
          identifier?: string;
          sourceName?: string;
          isStream?: boolean;
          isSeekable?: boolean;
      } | ((track, index) => boolean)

    Returns null | {
        track: Track<CommonUserData, CommonPluginInfo>;
        index: number;
    }

  • Get a range of tracks

    Parameters

    • start: number
    • Optional end: number

    Returns Track<CommonUserData, CommonPluginInfo>[]

  • Shift from previous tracks

    Returns null | Track<CommonUserData, CommonPluginInfo>