Basic Setup

To start using KawaLink, you need to initialize the Manager and define your Lavalink nodes.

Step 1: Initialize Manager

Create a new instance of the Manager and provide the necessary options.

const { Manager } =  require("kawalink");

client.manager = new Manager({
nodes: [
{
host: "localhost",
port: 2333,
password: "youshallnotpass",
secure: false,
}
],
send: (id, payload) => {
const guild = client.guilds.cache.get(id);
if (guild) guild.shard.send(payload);
}
});

Step 2: Connect to Nodes

Call the `init` method once your client is ready to start connecting to your Lavalink nodes.

client.once("ready", () => {
client.manager.init(client.user.id);
console.log(`Logged in as ${client.user.tag}`);
});

Step 3: Handle Raw Events

KawaLink needs to listen to raw voice events from Discord to handle voice connections properly.

client.on("raw", (d) => client.manager.updateVoiceState(d));