A lightweight and powerful lavalink client for nodejs.
Node.js v16.11.0 or newer is required
yarn add lavaclient # or npm install
yarn add [email protected] # or npm install
If you're looking for a Deno variant of lavaclient... We've got you covered!!
Even though the following examples use import syntax, Lavaclient also supports CommonJS!
import { Cluster, Node } from "lavaclient";
const info = { host: "localhost", port: 2333, password: "youshallnotpass" };
const lavalink = new Node({
connection: info,
sendGatewayPayload: (id, payload) => sendWithDiscordLib(id, payload),
});
// or for clustering:
const lavalink = new Cluster({
nodes: [ { id: "main", ...info } ],
sendGatewayPayload: (id, payload) => sendWithDiscordLib(id, payload),
});
lavalink.connect("870267613635309618");
Lavalink requires voice updates to play audio in a voice channel, this may vary from library to library.
What you need for correctly sending voice updates to lavalink:
(Cluster|Node)#handleVoiceUpdate
const results = await lavalink.rest.loadTracks(
"ytsearch:never gonna give you up",
);
await lavalink
.createPlayer("830616783199010857")
.connect("830638203739308053")
.play(results.tracks[0]);
this is a very poor way of playing music btw... checkout our discord.js example
Need some more help? Join our Support Server
lavaclient © 2018 - 2022