LavaCord
A simple and easy to use lavalink wrapper.
Documentation
lavacord.github.io/lavacord
Installation
For stable
yarn add lavacord
npm install lavacord
For Development
yarn add lavacord/lavacord
npm install lavacord/lavacord
LavaLink configuration
Download Lavalink from their GitHub releases
Put an application.yml
file in your working directory. Example
Run with java -jar Lavalink.jar
The issue tracker is for issues only
If you're having a problem with the module contact us in the Discord Server
Implementation
Start by creating a new Manager
passing an array of nodes and an object with user
the client's user id.
const { Manager } = require("lavacord");
const nodes = [
{ id: "1", host: "localhost", port: 2333, password: "youshallnotpass" }
];
const manager = new Manager(nodes, {
user: client.user.id,
send: (packet) => {
}
});
await manager.connect();
manager.on("error", (error, node) => {
error,
node
});
Resolving tracks using LavaLink REST API
const { Rest } = require("lavacord");
async function getSongs(search) {
const node = manager.idealNodes[0];
return Rest.load(node, search)
.catch(err => {
console.error(err);
return null;
});
}
getSongs("ytsearch:30 second song").then(songs => {
});
Joining and Leaving channels
const player = await manager.join({
guild: guildId,
channel: channelId,
node: "1"
});
await player.play(track);
player.once("error", error => console.error(error));
player.once("end", data => {
if (data.type === "TrackEndEvent" && data.reason === "replaced") return;
});
await manager.leave(guildId);