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.
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();
cleanup and finished manuallyreconnecting or changingNode when handling voice states