npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lavaqueue

v3.1.8

Published

A queue system for lavalink, backed by redis.

Downloads

10

Readme

Lavaqueue

lavalibs support server

A simple queue system for Lavalink, backed by Redis. Built as extension of my generic Lavalink wrapper.

How to use

const { Client: Lavaqueue } = require('lavaqueue');
const voice = new Lavaqueue({
  userID: '', // the user that will be sending audio
  password: '', // your lavalink password
  hosts: {
    rest: '', // your lavalink rest endpoint (include port and protocol)
    ws: '', // your lavalink ws endpoint (include port and protocol)
    redis: '', // your redis instance
  },
  send(guildID, packet) {
    // send the packet to the appropriate gateway connection
  },
  advanceBy(queue, { previous, remaining }) { // optional
    // called at the end of a track when the queue is otherwise unaware of how many tracks to
    // advance by; returns a number: 0 to repeat, negative to advance in reverse, positive to
    // advance forward
  },
});

async function connect() {
  const res = await voice.load('some identifier');
  const queue = voice.queues.get('some guild ID');

  await queue.player.join('channel id'); // join the voice channel
  await queue.add(...res.tracks.map(t => t.track)); // add songs to the queue
  await queue.start(); // start the queue
}

async function skip() {
  await voice.queues.get('some guild ID').next();
}

async function stop() {
  await voice.queues.get('some guild ID').stop();
}

Queues are resilient to crashes, meaning it's safe to blindly restart a queue: it will attempt to recover the previous song at the point the crash occurred. You can restart all currently playing queues by calling voice.queues.start(), although it is recommended to do so as infrequently as possible.

Reference

Queue

  • store: QueueStore
  • guildID: string
  • readonly player - the lavalink player
  • start(): Promise<boolean> - start the queue
  • add(...tracks: string[]): Promise<number> - add tracks to the queue
  • unshift(...tracks: string[]): Promise<number> - add tracks to the front of the queue
  • remove(track: string): PromiseLike<number> - remove a track from the queue
  • next(count: number = 1): Promise<boolean> - skip to the next song; pass negatives to advance in reverse, or 0 to repeat
  • sort(predicate?: (a: string, b: string) => number): Promise<number> - sort the upcoming tracks; resolves with the length of the queue
  • move(from: number, to: number): Promise<string[]> - move a track by index; resolves with the new list
  • shuffle(): Promise<string[]> - shuffle the list; resolves with the new list
  • splice(start: number, deleteCount?: number, ...tracks: string[]): Promise<string[]> - splice the list at the given position; works like Array#splice
  • trim(start: number, end: number): PromiseLike<string> - trim the queue to between the specified positions
  • stop(): Promise<void> - stop playback
  • clear(): PromiseLike<number> - clear the queue
  • current(): Promise<NP | null> - retrieve the current song: returns an object with properties track and position
  • tracks(start: number = 0, end: number = -1): Promise<string[]> - retrieves queued tracks
interface NP {
  position: number;
  track: string;
}

QueueStore extends Map<string, Queue>

  • client: Client
  • redis: Redis - the ioredis instance this queue store is using
  • start(filter?: (guildID: string) => boolean) - start all currently playing queues, with an optional filter callback
  • get(key: string): Queue - gets the specified queue, or creates one if none is found