Skip to content

execaman/discolink

Repository files navigation

🎯 Purpose

The goal of this library is to abstract away obvious steps involved in the process of acting as an intermediary between Lavalink and Discord to give developers a cleaner yet intuitive interface to work with.

✨ Features

  • Built-in queue system
  • Automatic player relocation
  • Built-in custom plugin support
  • Automatic relevant-node selection

⚙️ Requirements

  • Runtime - one of the following:
  • Library - any gateway client that supports:
    • sending raw payloads over the connection
    • receiving raw payloads from the connection
  • Lavalink - at least with the following configuration:
    • disabled local tracks - for unique track identifiers
    • disabled built-in youtube source utilising their plugin instead (recommended)

🕓 Configuration

Any gateway client library meeting the requirements above is supported, you can apply the following pseudocode (this is the basic approach):

import { Client } from "main-lib";
import { Player } from "discolink";

const client = new Client(...);

const player = new Player({
  nodes: [], // add your nodes
  async forwardVoiceUpdate(guildId, payload) {
    // send the given payload to your gateway connection
    client.guilds.cache.get(guildId).shard.send(payload);
  }
});

client.on("raw", (payload) => {
  // call the handler on gateway dispatch
  player.voices.handleDispatch(payload);
});

client.login();

📝 Additional Notes

  • Handle track end reasons other than cleanup and finished manually
  • Always check for reconnecting or changingNode when handling voice states

About

A javascript library for discord bots to interact with Lavalink

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •