- A simple Lavalink Client for EvolveJS
-
First of all you need to have NodeJS and EvolveJS installed...
-
Second you need to install Java (Note - You should install Java 13 as Lavalink has some problems with Java 11 and 14)
-
Download and install the latest version of Lavalink
npm i @evolvejs/evolava
- After you followed all the steps above, you can now initialize a new EvoLavaClient instance ONLY in Ready Event
- Start the Lavalink CI server by the command java -jar Lavalink.jar in the directory where you installed lavalink, make sure to have a application.yml
const { EvoLavaClient } = require("@evolvejs/evolava");
const { EvolveBuilder, CacheOptions, GatewayIntent } = require("@evolvejs/evolvejs");
const client = new EvolveBuilder()
.setToken("")
.setShards(1)
.enableCache(CacheOptions.GUILD)
.enableIntents(
GatewayIntent.GUILD, GatewayIntent.GUILD_MESSAGES, GatewayIntent.VOICE_STATES
).build();
client.on("clientReady", () => {
client.music = new EvoLavaClient(client, [
{
host: "localhost",
port: 2333,
password: "youshallnotpass"
}
]);
});
client.on("newMessage", (msg) => {
if(msg.content == "play") {
let player = client.music.spawn({
guild: msg.guild,
voiceChannel: msg.member.voiceState.channel,
textChannel: msg.channel,
volume: 100,
self: {
mute: false,
deaf: true
}
}, {
repeatTrack: false,
repeatQueue: false,
skipOnError: true
});
let song = player.search("Rick Astley - Never Gonna Give you up", msg.member, options: {
source: "yt",
add: false
});
if(!song) return;
player.play();
}
})
- Most of the logic of code was taken from LavaJS by the Projects.Me Team