waterlink
A new and improved Lavalink client for discord.js
Installing
# yarn
yarn add waterlink
# npm
npm i waterlink
How can I use it?
Its pretty easy!
const { Client } = require('discord.js');
const { Manager } = require('waterlink');
const client = new Client();
client.player = null;
client.on('ready', () => {
client.player = new Manager(client, [
{
host: 'nodehost',
password: 'nodepassword',
post: 'nodeport'
}
], {
userId: client.user.id,
shards: 1
});
});
client.on('message', async(msg) => {
if (msg.content === "!play") {
const player = client.player.createConnection({
guild: 'guildid',
voiceChannel: 'voicechannel',
host: client.player.nodes.first().host
});
const songs = await player.getTracks('ytsearch:trap music').tracks
const song = songs[0];
player.play(song.track);
}
})