/Ferralink

Primary LanguageJavaScript

Discord npm version npm download GitHub issues

🎶 FerraLink

A Simple but powerful Lavalink Client for your JavaScript Discord Bot!

🔨 Requirements

  • Node.js >= 16.9.0 or Latest.
  • Discord.js >= 14.6.0.

📖 Documentation

📂 Implementation

📦 How to Install FerraLink

  1. Go to console and write this npm i ferra-link

  2. Having a Host with Lavalink Client (Recommended) or using it in Localhost

  3. Do not forget Giving the Intents for Voice Channels

How to Setup our FerraLink

1. Declaring FerraLink

const { FerraLink } = require("ferra-link");

2. Defining your Nodes

  1. This setp depends if you have any Hosting to get your Lavalink Server.

  2. The password is from your application.yml.

const nodes = [{
name: "Node",
url: "localhost:2333",
auth: "youshallpass",
secure: false
}];

3. Set the Initilizer of Ferralink

Creating in a way like the code example you can import the bot and nodes.

client.FerraLink = new FerraLink(client, nodes, {
spotify: {
 playlistLimit: "Playlist search limit here", //default limit is 5 = 500.
 albumLimit: "Album search limit here", //default limit is 5 = 500.
 artistLimit: "Artist search limit here", //default limit is 5 = 500.
 searchMarket: "searchMarket(ISO code) here", //default searchMarket is US.
 clientID: "Your spotify clientId here",
 clientSecret: "Your spotify clientSecret here"
}
});

4. A small example to create play command.

const player = await client.FerraLink.createPlayer({
guildId: message.guild.id,
voiceId: message.member.voice.channel.id,
textId: message.channel.id,
shardId: message.guild.shardId,
volume: 100,
deaf: true,
});

const resolve = await client.FerraLink.search(queue, { engine: "spsearch" }); // spsearch is work for search spotify tracks.
const { loadType, tracks, playlistInfo } = resolve;

if (loadType === "NO_MATCHES" || !tracks.length) return;

if (loadType === "PLAYLIST_LOADED") {
for (const track of tracks) {
player.queue.add(track);
}
if (!player.queue.current && !player.paused) await player.play();
message.channel.send({content: `Added ${player.queue.length} tracks from ${playlistInfo.name}`});
} else if (loadType === "SEARCH_RESULT" || loadType === "TRACK_LOADED") {
player.queue.add(tracks[0]);
if (!player.queue.current && !player.paused) await player.play();
message.channel.send({content: `Queued ${tracks[0].info.title}`});
} else return;

Getting the Events (shoukaku)

You can access event with the help of client.FerraLink.shoukaku.on().....

Event Name Elements Description
ready name, resumed Event of the node connection.
error name, error Event of the node error.
close name, code, reason Event of the node close.
disconnect name, players, move Event of the node disconnect.
debug name, reason Event of the node debug.

Getting the Events (FerraLink)

You can access event with the help of client.FerraLink.on().....

Event Name Elements Description
trackStart player, track Event of the track start.
trackEnd player, track Event of the track end.
queueEnd player Event of the queue end.
PlayerClosed player, data Event of the player close.
trackException player, data Event of the track exception.
PlayerUpdate player, data Event of the player update.
trackStuck player, data Event of the track stuck.
PlayerResumed player Event of the player resumed.
playerDestroy player Event of the player destroyed.
PlayerCreate player Event of the player create.

Contributors

Deivu as the owner of Shoukaku.

Vkamsingh, Corgi as the owner of FerraLink.

Prahar as the maintainer of FerraLink Docs.