ssMMiles / lavaclient

A simple, easy-to-use, and flexible lavalink client for node.js

Home Page:https://lavaclient.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A lightweight and powerful lavalink client for nodejs.

  • Easy-to-use: lavaclient has a neat and user-friendly promise-based api.
  • Performant: designed to be small and lightweight, it's a great choice for any project.
  • Library Agnostic: lavaclient doesn't require you to use a specific discord library. Use anything you want!

Support Server

Installation

node.js v14 or newer is required

Stable
yarn add lavaclient # or npm install
Beta (may be outdated)
yarn add lavaclient@beta # or npm install

Usage

Setup

import { Node, Cluster } 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");

Handling Voice Updates

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:

  1. A connection to the Discord gateway.
  2. Raw Voice State and Server updates
  3. Passing the data of the voice update to (Cluster|Node)#handleVoiceUpdate

Playing Music

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

Deno

If you're looking for a Deno variant of lavaclient... I've got you covered!!


lavaclient © 2018 - 2022

About

A simple, easy-to-use, and flexible lavalink client for node.js

https://lavaclient.js.org

License:Apache License 2.0


Languages

Language:TypeScript 100.0%