This package has been deprecated

Author message:

removed

lavalink-dev-version
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Discord npm npm downloads NPM version Build Status Codacy Badge Open Source Love dependencies Status devDependencies Status NPM

discord.js-lavalink

A Discord.js lavalink client for discord.js@12.0.0-dev version.

Documentation

mrjacz.github.io/discord.js-lavalink

Installation

For stable npm install discord.js-lavalink

For Development npm install mrjacz/discord.js-lavalink

LavaLink configuration

Download from the CI server

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 PlayerManager passing an array of nodes and an object with user the client's user id and shards The total number of shards your bot is operating on.

const { PlayerManager } = require("discord.js-lavalink");
 
const nodes = [
    { host: "localhost", port: 80, region: "asia", password: "youshallnotpass" }
];
 
const manager = new PlayerManager(client, nodes, {
    user: client.user.id, // Client id
    shards: shardCount // Total number of shards your bot is operating on
});

Resolving tracks using LavaLink REST API

async function getSongs(string) {
    const res = await snekfetch.get(`http://localhost:2333/loadtracks?identifier=${string}`)
        .set("Authorization", "youshallnotpass")
        .catch(err => {
            console.error(err);
            return null;
        });
    if (!res) throw "There was an error, try again";
    if (!res.body.length) throw "No tracks found";
    return res.body;
}
 
getSongs("ytsearch:30 second song").then(songs => {
    // handle loading of the tracks somehow ¯\_(ツ)_/¯
});

Joining and Leaving channels

// Join
manager.join({
    guild: guildId // Guild id
    channel: channelId // Channel id
    host: "localhost" // lavalink host, based on array of nodes
}).then(player => {
    player.play(track); // Track is a base64 string we get from Lavalink REST API
 
    player.once("error", error => console.error(error));
    player.once("end", data => {
        if (data.reason === "REPLACED") return; // Ignore REPLACED reason to prevent skip loops
        // Play next song
    });
});
 
// Leave voice channel and destory Player
manager.leave(guildId); // Player ID aka guild id

For a proper example look at Testing/app.js

Package Sidebar

Install

npm i lavalink-dev-version

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

31.7 kB

Total Files

8

Last publish

Collaborators

  • emirkabal