@ariijs/lavalink-client
v3.0.0
Published
arii's extras for lavalink-client: stamped tracks, a reversible shuffle that survives any queue store, skip by position or title, a real previous(), and Deezer ARL pools. ESM and CommonJS.
Maintainers
Readme
@ariijs/lavalink-client
arii's extras for lavalink-client, as drop-in subclasses. ESM and CommonJS, typed.
- every queued track is stamped with a random
cidin itsuserData, so the same song queued twice is still two entries; - a reversible shuffle (
toggleShuffle) that remembers the order and gives it back, with that state saved in the queue store, so a restored queue is still shuffled; skip(position | title): skip to the third track, or to "the one that sounds like chandelier";- a
previous()that goes back one track for real; - a Deezer ARL for each play: tracks from Deezer, Spotify and Apple Music (which LavaSrc plays through Deezer) get the ARL you pick as they start, in that request to Lavalink only, so an ARL never sits in a queue or its store, and your accounts can change at any time.
install
npm install lavalink-client @ariijs/lavalink-clientlavalink-client is a peer dependency (2.11 or newer).
usage
import { LavalinkManager } from "@ariijs/lavalink-client";
import type { Track } from "lavalink-client"; // types that this package doesn't redefine
const lavalink = new LavalinkManager({
nodes: [{ id: "main", host: "127.0.0.1", port: 2333, authorization: "password" }],
sendToShard: (guildId, payload) => client.guilds.cache.get(guildId)?.shard.send(payload),
client: { id: client.user.id },
// optional: the ARL a track plays with this time (null: Lavalink's own)
deezer: { arlFor: async (track, player) => myAccounts.next() },
// optional: play a track from a file you keep (Lavalink's local source) instead of its stream
cache: { fileFor: async (track, player) => myFiles.encodedFor(track) },
});
const player = lavalink.createPlayer({ guildId, voiceChannelId, textChannelId });
await player.queue.add(tracks); // each track gets userData.cid
await player.queue.toggleShuffle(); // on; toggleShuffle() again turns it off and restores the order
await player.skip(3); // to the third of the next tracks
await player.skip("chandelier", { withAuthor: true }); // by similarity
await player.previous(); // back one trackEvery class is a subclass of lavalink-client's, so everything else works as documented there. Typed userData:
interface MyData extends TrackUserData {
requestedFrom: string;
}
const lavalink = new LavalinkManager<Player<MyData>>({ ... });See CHANGELOG.md for what changed in 2.0.
